def _query(self, **kwargs): host = kwargs.get('host') keywords = kwargs.get('keywords') page = kwargs.get('page') try: api = MediasCommon(host=host) images, attrs = api.search({'keywords': keywords, 'perpage': 100, 'page': page}) except Exception, error: images, attrs = [], {}
def _query(self, **kwargs): host = kwargs.get('host') keywords = kwargs.get('keywords') page = kwargs.get('page') try: api = MediasCommon(host=host) images, info = api.search({'api_key': API_KEY, 'keywords': keywords, 'max_results': 100, 'page': page}) except Exception, error: images, info = [], {}
def get_queryset(self): results = [] keywords = self.request.GET.get('keywords') page = self.request.GET.get('page') or 1 tags = keywords.split(' ') if len(tags) > 0: api = MediasCommon(host='vine') videos, info = api.search({'keywords': tags[0], 'page': int(page)}) info['page'] = int(page) results = self._handling_results(videos=videos, info=info) return results
def _query(self, **kwargs): host = kwargs.get('host') keywords = kwargs.get('keywords') page = kwargs.get('page') try: api = MediasCommon(host=host) images, attrs = api.search({ 'keywords': keywords, 'perpage': 100, 'page': page }) except Exception, error: images, attrs = [], {}
def _query(self, **kwargs): host = kwargs.get('host') keywords = kwargs.get('keywords') page = kwargs.get('page') try: api = MediasCommon(host=host) images, info = api.search({ 'api_key': API_KEY, 'keywords': keywords, 'max_results': 100, 'page': page }) except Exception, error: images, info = [], {}
def _do_queryset(self, host, keywords): converting = unicodedata.normalize('NFKD', keywords).encode('ascii', 'ignore') cache_key_name = '%s_%s' % (host, converting.replace(' ', '_').lower()) images = cache.get(cache_key_name) need_search = False if images is None: need_search = True elif len(images) == 0: need_search = True if need_search: api = MediasCommon(host=host) images = api.search({'keywords': keywords, 'max_results': 100}) cache.set(cache_key_name, images, 86400) return images
def get_queryset(self): keywords = self.request.GET.get('keywords') converting = unicodedata.normalize('NFKD', keywords).encode('ascii', 'ignore') cache_key_name = 'youtube_%s' % converting.replace(' ', '_').lower() videos = cache.get(cache_key_name) need_search = False if videos is None: need_search = True elif len(videos) == 0: need_search = True if need_search: try: api = MediasCommon(host='youtube', client_secret=CLIENT_SECRET) videos = api.search({'keywords': keywords, 'max_results': 50}) cache.set(cache_key_name, videos, 86400) except Exception, error: pass