def get_results(self): cache_key = self._get_cache_key() results = cache.get(cache_key) if results is None: finish_by = time.time() + 20 search_results = auto_search( self.cleaned_data['query'], order_by=self.cleaned_data['order_by'], api_keys=API_KEYS) results = [] for vidscraper_video in intersperse_results(search_results, 40): try: vidscraper_video.load() except VidscraperError: pass except Exception: logging.error('error while loading search result: %r', vidscraper_video.url, exc_info=True) else: results.append(vidscraper_video) if time.time() > finish_by: break # don't take forever! cache.set(cache_key, results) for vidscraper_video in results: video = Video.from_vidscraper_video(vidscraper_video, commit=False) if video.embed_code or video.file_url: yield video
def get_results(self): cache_key = self._get_cache_key() results = cache.get(cache_key) if results is None: finish_by = time.time() + 20 search_results = auto_search( self.cleaned_data["query"], order_by=self.cleaned_data["order_by"], api_keys=API_KEYS ) results = [] for vidscraper_video in intersperse_results(search_results, 40): try: vidscraper_video.load() except VidscraperError: pass except Exception: logging.error("error while loading search result: %r", vidscraper_video.url, exc_info=True) else: results.append(vidscraper_video) if time.time() > finish_by: break # don't take forever! cache.set(cache_key, results) for vidscraper_video in results: video = Video.from_vidscraper_video(vidscraper_video, commit=False) if video.embed_code or video.file_url: yield video
def get_results(self): cache_key = self._get_cache_key() results = cache.get(cache_key) if results is None: finish_by = time.time() + 20 search_results = auto_search(self.cleaned_data['q'], order_by=self.cleaned_data['order_by'], api_keys=self.get_search_api_keys()) results = [] for vidscraper_video in intersperse_results(search_results, 40): try: vidscraper_video.load() except VidscraperError: pass else: results.append(vidscraper_video) if time.time() > finish_by: break # don't take forever! cache.set(cache_key, results) for vidscraper_video in results: video = Video.from_vidscraper_video(vidscraper_video, commit=False) if video.embed_code or video.file_url: yield video