예제 #1
0
파일: airframe.py 프로젝트: puwkin/airframe
 def flickr_mode(self):
     # Connect to Flickr
     logging.debug("list of tags: %s" % self.photo_tags)
     self.flickr = Flickr()
     if len(self.photo_tags) > 0:
         photo_filenames = self.flickr.get_tagged(self.photo_tags, self.photo_count, download_dir=self.download_dir)
     else:
         photo_filenames = self.flickr.get_recent(self.photo_count,download_dir=self.download_dir)
     return photo_filenames
예제 #2
0
def getImage(location, service='flickr'):

    returnJson = {}

    print(" 1. my token is " + request.get_cookie("insta_auth_token"))

    if service == 'flickr':
        ps = Flickr()
    elif service == 'insta':
        ps = Instagram()
    print("2. my token is " + request.get_cookie("insta_auth_token"))

    print("GETTING SHIT")
    ps.photo_lookup(location)
    print(" 3. my token is " + request.get_cookie("insta_auth_token"))
    photo = ps.get_next_photo()
    print(" 4. my token is " + request.get_cookie("insta_auth_token"))
    print(photo)

    return json.dumps(photo)
예제 #3
0
def home():
    templates = {'home': 'home.html', 'serp': 'serp.html'}
    template = templates.get('home')
    context = {
        'data': {
            'title': '',
            'link': '',
            'description': '',
            'modified': '',
            'generator': '',
            'items': [],
        }
    }
    query = request.args.get('q', '')
    params = {'format': 'json', 'tagmode': 'all'}

    if query:
        template = templates.get('serp')
        context['query'] = query
        params['tags'] = query
        params['tagmode'] = 'any'

    context['data'] = Flickr().public_feed(params)
    return render_template(template, **context)
예제 #4
0
    {'start': '2015-08-1', 'end': '2015-09-1'},
    {'start': '2015-11-1', 'end': '2016-12-1'}
]

places = [
    {'name': "NewYork", 'id': ".skCPTpTVr.Q3WKW"},
    {'name': "Boston", 'id': "5MvaTZJTUbx1uPnP"},
    {'name': "Beijing", 'id': "vQ6vOjpTU7_QE6S8"},
    {'name': "Hongkong", 'id': "JAJiM7JTU78IjzqC"}
]

results = {}
for place in places:
    place_results = results[place.get('name')] = {}
    for time in times:
        query = Flickr({
            'place_id': place.get('id'),
            'sort': 'interestingness-desc',
            'per_page': 100,
            # 'text': 'landscape',
            'min_taken_date': parseTime(time.get('start')),
            'max_taken_date': parseTime(time.get('end'))
        })
        # place_results[time.get('start')] = query.results
        # The above yields a lot of unused json. Below just the title, and image url.
        place_results[time.get('start')] = [{'title': r.get('title'),'url': r.get('url')} for r in query.results]



with open("kini.json", 'w') as outfile:
    json.dump(results, outfile, indent=4, sort_keys=True)