def movie(self, imdb, title, localtitle, aliases, year): if isinstance(self._get_scraper(title), NoResultsScraper): return None self._request = self.scraper._request simple_info = {} simple_info['title'] = source_utils.clean_title(title) simple_info['year'] = year return simple_info
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): if isinstance(self._get_scraper(tvshowtitle), NoResultsScraper): return None self._request = self.scraper._request simple_info = {} simple_info['show_title'] = re.sub( r'\s+', ' ', source_utils.clean_title(tvshowtitle).replace(year, '')) simple_info['year'] = year return simple_info
def movie_query(self, title, year, single_query=False, caller_name=None): title = strip_accents(title) if self.caller_name is None: if caller_name is None: caller_name = get_caller_name() self.caller_name = caller_name self.title = source_utils.clean_title(title) self.year = year full_query = '%s %s' % (title, year) use_cache_only = self._get_cache(full_query) if use_cache_only: return self._get_movie_results() skip_set_cache = False try: self._url = self._find_url() if self._url is None: self._set_cache(full_query) return self._get_movie_results() movie = lambda query: self._query_thread(query, [self.filter_movie_title]) queries = [movie(self.title + ' ' + self.year)] try: alternative_title = replace_text_with_int(self.title) if self.title != alternative_title: queries.append(movie(alternative_title + ' ' + self.year)) except: pass wait_threads(queries) if len( self._temp_results ) == 0 and not single_query and not self._request.self.has_timeout_exc: self._set_cache(full_query) skip_set_cache = True wait_threads([movie(self.title)]) if not skip_set_cache: self._set_cache(full_query) return self._get_movie_results() except: if not skip_set_cache: self._set_cache(full_query) return self._get_movie_results()
def episode_query(self, simple_info, auto_query=True, single_query=False, caller_name=None, exact_pack=False): simple_info['show_title'] = strip_accents(simple_info['show_title']) if self.caller_name is None: if caller_name is None: caller_name = get_caller_name() self.caller_name = caller_name simple_info['show_aliases'] = list(set(simple_info['show_aliases'])) if '.' in simple_info['show_title']: no_dot_show_title = simple_info['show_title'].replace('.', '') simple_info['show_aliases'].append(no_dot_show_title) for alias in simple_info['show_aliases']: if '.' in alias: simple_info['show_aliases'].append(alias.replace('.', '')) self.simple_info = simple_info self.year = simple_info['year'] self.country = simple_info['country'] self.show_title = source_utils.clean_title(simple_info['show_title']) if self.year in self.show_title: self.show_title_fallback = re.sub( r'\s+', ' ', self.show_title.replace(self.year, '')) else: self.show_title_fallback = None self.episode_title = source_utils.clean_title( simple_info['episode_title']) self.season_x = simple_info['season_number'] self.episode_x = simple_info['episode_number'] self.season_xx = self.season_x.zfill(2) self.episode_xx = self.episode_x.zfill(2) #full_query = '%s %s %s %s %s' % (self.show_title, self.year, self.season_xx, self.episode_xx, self.episode_title) # use_cache_only = self._get_cache(full_query) # if use_cache_only: # return self._get_episode_results() try: self._url = self._find_url() if self._url is None: #self._set_cache(full_query) return self._get_episode_results() if auto_query is False: wait_threads([self._episode('')]) #self._set_cache(full_query) return self._get_episode_results() def query_results(): if DEV_MODE: if self.caller_name != 'eztv': wait_threads([ self._season(self.show_title + ' S%s' % self.season_xx) ]) else: wait_threads([ self._episode(self.show_title + ' S%sE%s' % (self.season_xx, self.episode_xx)) ]) return # specials if self.season_x == '0': wait_threads([ self._episode_special(self.show_title + ' %s' % self.episode_title) ]) #self._set_cache(full_query) return queries = [ self._episode(self.show_title + ' S%sE%s' % (self.season_xx, self.episode_xx)) ] if single_query: #self._set_cache(full_query) wait_threads(queries) return if exact_pack: queries = queries + [ self._season_and_pack(self.show_title + '.S%s.' % self.season_xx) ] else: queries = queries + [ self._season(self.show_title + ' Season ' + self.season_x), self._season(self.show_title + ' S%s' % self.season_xx), self._pack(self.show_title + ' Seasons'), self._season_and_pack(self.show_title + ' Complete') ] if simple_info.get('isanime', False) and simple_info.get( 'absolute_number', None) is not None: queries.insert( 0, self._episode(self.show_title + ' %s' % simple_info['absolute_number'])) if self._use_thread_for_info: wait_threads([queries[0]]) else: wait_threads(queries) query_results() if len(self._temp_results ) == 0 and self.show_title_fallback is not None: self.show_title = self.show_title_fallback self.simple_info['show_title'] = self.show_title_fallback query_results() #self._set_cache(full_query) return self._get_episode_results() except: #self._set_cache(full_query) return self._get_episode_results()