コード例 #1
0
 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 = [], {}
コード例 #2
0
ファイル: flickr.py プロジェクト: quantm/custom_django_oscar
 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 = [], {}
コード例 #3
0
    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
コード例 #4
0
ファイル: vine.py プロジェクト: quantm/custom_django_oscar
    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
コード例 #5
0
 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 = [], {}
コード例 #6
0
ファイル: flickr.py プロジェクト: quantmScubism/django_oscar
 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 = [], {}
コード例 #7
0
    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
コード例 #8
0
    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
コード例 #9
0
ファイル: youtube.py プロジェクト: quantm/custom_django_oscar
    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
コード例 #10
0
ファイル: youtube.py プロジェクト: quantmScubism/django_oscar
    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