Beispiel #1
0
#!/usr/bin/python

import flickrquery

results = flickrquery.run_flickr_query('madrid', 10, startDate='1/2/2010', endDate='10/2/2010')

print len(results)
    os.mkdir(args.output_dir)
if not os.path.exists(args.output_dir):
    print "Cannot create output directory, exiting."
    exit()

all_results = {}

query_results_file = os.path.join(args.output_dir, "query_results.txt")
if not os.path.exists(query_results_file) or not args.load_cache:

    queries = args.query.split(";")

    for q in queries:
        print q
        results = flickrquery.run_flickr_query(
            query_args={"text": q}, max_photos=args.num_images, startDate=args.start_date, endDate=args.end_date
        )

        print "Found %d images for query: %s" % (len(results), q)
        for photo_id, data in results.items():
            all_results[photo_id] = data

    # MAX_IMAGES_DIRECTORY = 1000
    # directory_number = 1
    num_images_in_directory = 0

    num_images = 0
    num_download = 0

    print "Downloading %d images." % len(all_results.keys())
Beispiel #3
0
    url_original = 'http://farm%s.staticflickr.com/%s/%s_%s_o.%s' % (data['farm'], data['server'], data['id'], data['originalsecret'], data['originalformat'])
  else:
    url_original = 'http://farm%s.staticflickr.com/%s/%s_%s_o.jpg' % (data['farm'], data['server'], data['id'], data['secret'])
  url_large = 'http://farm%s.staticflickr.com/%s/%s_%s_b.jpg' % (data['farm'], data['server'], data['id'], data['secret'])
  url_normal = 'http://farm%s.staticflickr.com/%s/%s_%s.jpg' % (data['farm'], data['server'], data['id'], data['secret'])
  return [url_original,url_large,url_normal]

query = args.query

all_results = {}

endDate = args.end_date;
if endDate == 'today':
  endDate = time.strftime("%d/%m/%Y")

results = flickrquery.run_flickr_query(query, args.num_images, startDate=args.start_date, endDate=endDate)

print 'Found %d images for query: %s' % (len(results), query)
for photo_id, data in results.items():
  all_results[photo_id] = data;

num_images = 0

result_f = open(args.output, 'w')

for photo_id,data in all_results.items():
  urls = generate_urls(data)
  result_f.write('%s %s %s %s\n' % (photo_id, urls[0], urls[1], urls[2]))
  num_images = num_images + 1
  if num_images >= args.num_images:
    break