def filterBadReleases(name): """ Filters out non-english and just all-around stupid releases by comparing them to the resultFilters contents. name: the release name to check Returns: True if the release name is OK, False if it's bad. """ cp = CompleteParser() cpr = cp.parse(name) parse_result = cpr.parse_result # use the extra info and the scene group to filter against check_string = '' if parse_result.extra_info: check_string = parse_result.extra_info if parse_result.release_group: if check_string: check_string = check_string + '-' + parse_result.release_group else: check_string = parse_result.release_group # if there's no info after the season info then assume it's fine if not check_string: return True # if any of the bad strings are in the name then say no for x in resultFilters + sickbeard.IGNORE_WORDS.split(','): if re.search('(^|[\W_])' + x + '($|[\W_])', check_string, re.I): logger.log(u"Invalid scene release: " + name + " contains " + x + ", ignoring it", logger.DEBUG) return False return True
def _addCacheEntry(self, name, url, season=None, episodes=None, tvdb_id=0, tvrage_id=0, quality=None, extraNames=[]): """Return False|None Parse the name and try to get as much info out of it as we can Will use anime regex's if this is called from fanzub On a succesfull parse it will add the parsed infos into the cache.db This dosen't mean the parsed result is usefull """ myDB = self._getDB() show = None if tvdb_id: show = helpers.findCertainShow(sickbeard.showList, tvdb_id) # if we don't have complete info then parse the filename to get it for curName in [name] + extraNames: cp = CompleteParser(show=show) cpr = cp.parse(curName) if cpr.sxxexx and cpr.parse_result: break else: return False episodeText = "|"+"|".join(map(str, cpr.episodes))+"|" # get the current timestamp curTimestamp = int(time.mktime(datetime.datetime.today().timetuple())) myDB.action("INSERT INTO "+self.providerID+" (name, season, episodes, tvrid, tvdbid, url, time, quality, release_group, proper) VALUES (?,?,?,?,?,?,?,?,?,?)", [name, cpr.season, episodeText, 0, cpr.tvdbid, url, curTimestamp, cpr.quality, cpr.release_group, int(cpr.is_proper)])
def findSeasonResults(self, show, season, scene=False): itemList = [] results = {} for curString in self._get_season_search_strings(show, season, scene): itemList += self._doSearch(curString, show=show) for item in itemList: (title, url) = self._get_title_and_url(item) # parse the file name cp = CompleteParser(show=show) cpr = cp.parse(title) if not cpr: continue # make sure we want the episode wantEp = True for epNo in cpr.episodes: if not show.wantEpisode(cpr.season, epNo, cpr.quality): wantEp = False break if not wantEp: logger.log(u"Ignoring result "+title+" because we don't want an episode that is "+Quality.qualityStrings[cpr.quality], logger.DEBUG) continue logger.log(u"Found result " + title + " at " + url, logger.DEBUG) # make a result object epObj = [] for curEp in cpr.episodes: epObj.append(show.getEpisode(cpr.season, curEp)) result = self.getResult(epObj) result.url = url result.name = title result.quality = cpr.quality result.release_group = cpr.release_group result.is_proper = cpr.is_proper if len(epObj) == 1: epNum = epObj[0].episode elif len(epObj) > 1: epNum = MULTI_EP_RESULT logger.log(u"Separating multi-episode result to check for later - result contains episodes: " + str(cpr.episodes), logger.DEBUG) elif len(epObj) == 0: epNum = SEASON_RESULT result.extraInfo = [show] logger.log(u"Separating full season result to check for later", logger.DEBUG) if epNum in results: results[epNum].append(result) else: results[epNum] = [result] return results
def validate_name(pattern, multi=None, file_only=False, abd=False, anime=False): ep = _generate_sample_ep(multi, abd, anime) new_name = ep.formatted_filename(pattern, multi) + '.ext' new_path = ep.formatted_dir(pattern, multi) if not file_only: new_name = ek.ek(os.path.join, new_path, new_name) if not new_name: logger.log(u"Unable to create a name out of " + pattern, logger.DEBUG) return False logger.log(u"Trying to parse " + new_name, logger.DEBUG) cp = CompleteParser(ep.show) cpr = cp.parse(new_name) if not cpr.parse_result: logger.log(u"Unable to parse " + new_name + ", not valid", logger.DEBUG) return False logger.log("The name " + new_name + " parsed into " + str(cpr), logger.DEBUG) if abd: if cpr.air_date != ep.airdate: return False elif anime: if cpr.ab_episode_numbers != [ x.absolute_number for x in [ep] + ep.relatedEps ]: logger.log( u"Air date incorrect in parsed episode, pattern isn't valid", logger.DEBUG) return False else: if cpr.season != ep.season: logger.log( u"Season incorrect in parsed episode, pattern isn't valid", logger.DEBUG) return False if cpr.episodes != [x.episode for x in [ep] + ep.relatedEps]: logger.log( u"Episode incorrect in parsed episode, pattern isn't valid", logger.DEBUG) return False return True
def filterBadReleases(name): """ Filters out non-english and just all-around stupid releases by comparing them to the resultFilters contents. name: the release name to check Returns: True if the release name is OK, False if it's bad. """ """ try: parse_result = parse_result_wrapper(None,name) except InvalidNameException: logger.log(u"Unable to parse the filename "+name+" into a valid episode", logger.WARNING) return False """ cp = CompleteParser() cpr = cp.parse(name) parse_result = cpr.parse_result # use the extra info and the scene group to filter against check_string = '' if parse_result.extra_info: check_string = parse_result.extra_info if parse_result.release_group: if check_string: check_string = check_string + '-' + parse_result.release_group else: check_string = parse_result.release_group # if there's no info after the season info then assume it's fine if not check_string: return True # if any of the bad strings are in the name then say no for x in resultFilters + sickbeard.IGNORE_WORDS.split(','): if re.search('(^|[\W_])' + x + '($|[\W_])', check_string, re.I): logger.log( u"Invalid scene release: " + name + " contains " + x + ", ignoring it", logger.DEBUG) return False return True
def _addCacheEntry(self, name, url, season=None, episodes=None, tvdb_id=0, tvrage_id=0, quality=None, extraNames=[]): myDB = self._getDB() # if we don't have complete info then parse the filename to get it for curName in [name] + extraNames: try: cp = CompleteParser() cpr = cp.parse(curName) except: logger.log(u"Unable to parse the filename "+curName+" into a valid episode", logger.DEBUG) return False episodeText = "|" + "|".join(map(str, cpr.episodes)) + "|" # get the current timestamp curTimestamp = int(time.mktime(datetime.datetime.today().timetuple())) myDB.action("INSERT INTO " + self.providerID + " (name, season, episodes, tvrid, tvdbid, url, time, quality) VALUES (?,?,?,?,?,?,?,?)", [name, cpr.season, episodeText, 0, cpr.tvdbid, url, curTimestamp, cpr.quality])
def _addCacheEntry(self, name, url, season=None, episodes=None, tvdb_id=0, tvrage_id=0, quality=None, extraNames=[]): """Return False|None Parse the name and try to get as much info out of it as we can Will use anime regex's if this is called from fanzub On a succesfull parse it will add the parsed infos into the cache.db This dosen't mean the parsed result is usefull """ myDB = self._getDB() show = None if tvdb_id: show = helpers.findCertainShow(sickbeard.showList, tvdb_id) # if we don't have complete info then parse the filename to get it for curName in [name] + extraNames: cp = CompleteParser(show=show) cpr = cp.parse(curName) if cpr.sxxexx and cpr.parse_result: break else: return False episodeText = "|" + "|".join(map(str, cpr.episodes)) + "|" # get the current timestamp curTimestamp = int(time.mktime(datetime.datetime.today().timetuple())) myDB.action( "INSERT INTO " + self.providerID + " (name, season, episodes, tvrid, tvdbid, url, time, quality, release_group, proper) VALUES (?,?,?,?,?,?,?,?,?,?)", [ name, cpr.season, episodeText, 0, cpr.tvdbid, url, curTimestamp, cpr.quality, cpr.release_group, int(cpr.is_proper) ])
def validate_name(pattern, multi=None, file_only=False, abd=False, anime=False): ep = _generate_sample_ep(multi, abd, anime) new_name = ep.formatted_filename(pattern, multi) + '.ext' new_path = ep.formatted_dir(pattern, multi) if not file_only: new_name = ek.ek(os.path.join, new_path, new_name) if not new_name: logger.log(u"Unable to create a name out of "+pattern, logger.DEBUG) return False logger.log(u"Trying to parse " + new_name, logger.DEBUG) cp = CompleteParser(ep.show) cpr = cp.parse(new_name) if not cpr.parse_result: logger.log(u"Unable to parse "+new_name+", not valid", logger.DEBUG) return False logger.log("The name "+new_name + " parsed into " + str(cpr), logger.DEBUG) if abd: if cpr.air_date != ep.airdate: return False elif anime: if cpr.ab_episode_numbers != [x.absolute_number for x in [ep] + ep.relatedEps]: logger.log(u"Air date incorrect in parsed episode, pattern isn't valid", logger.DEBUG) return False else: if cpr.season != ep.season: logger.log(u"Season incorrect in parsed episode, pattern isn't valid", logger.DEBUG) return False if cpr.episodes != [x.episode for x in [ep] + ep.relatedEps]: logger.log(u"Episode incorrect in parsed episode, pattern isn't valid", logger.DEBUG) return False return True
def _analyze_name(self, name, file=True): """ Takes a name and tries to figure out a show, season, and episode from it. name: A string which we want to analyze to determine show info from (unicode) Returns a (tvdb_id, season, [episodes]) tuple. The first two may be None and episodes may be [] if none were found. """ logger.log(u"Analyzing name "+repr(name)) to_return = (None, None, []) if not name: return to_return cp = CompleteParser(log=self._log, tvdbActiveLookUp=True) cpr = cp.parse(name) self.is_proper = cpr.is_proper self.series_name = cpr.series_name return (cpr.tvdbid, cpr.season, cpr.episodes)
def _analyze_name(self, name, file=True): """ Takes a name and tries to figure out a show, season, and episode from it. name: A string which we want to analyze to determine show info from (unicode) Returns a (tvdb_id, season, [episodes]) tuple. The first two may be None and episodes may be [] if none were found. """ logger.log(u"Analyzing name " + repr(name)) to_return = (None, None, []) if not name: return to_return cp = CompleteParser(log=self._log, tvdbActiveLookUp=True) cpr = cp.parse(name) self.is_proper = cpr.is_proper self.series_name = cpr.series_name return (cpr.tvdbid, cpr.season, cpr.episodes)
def findSeasonResults(self, show, season, scene): itemList = [] results = {} for cur_string in self._get_season_search_strings(show, season): itemList += self._doSearch(cur_string) for item in itemList: (title, url) = self._get_title_and_url(item) quality = self.getQuality(item) # parse the file name cp = CompleteParser(show=show) cpr = cp.parse(title) if not cpr: continue """ try: #myParser = NameParser(False) #parse_result = myParser.parse(title) parse_result = None except InvalidNameException: logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING) continue if not show.air_by_date: # this check is meaningless for non-season searches if (parse_result.season_number != None and parse_result.season_number != season) or (parse_result.season_number == None and season != 1): logger.log(u"The result " + title + " doesn't seem to be a valid episode for season " + str(season) + ", ignoring") continue # we just use the existing info for normal searches actual_season = season actual_episodes = parse_result.episode_numbers else: if not parse_result.air_by_date: logger.log(u"This is supposed to be an air-by-date search but the result " + title + " didn't parse as one, skipping it", logger.DEBUG) continue myDB = db.DBConnection() sql_results = myDB.select("SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?", [show.tvdbid, parse_result.air_date.toordinal()]) if len(sql_results) != 1: logger.log(u"Tried to look up the date for the episode " + title + " but the database didn't give proper results, skipping it", logger.WARNING) continue actual_season = int(sql_results[0]["season"]) actual_episodes = [int(sql_results[0]["episode"])] """ # make sure we want the episode wantEp = True for epNo in cpr.episodes: if not show.wantEpisode(cpr.season, epNo, cpr.quality): wantEp = False break if not wantEp: logger.log(u"Ignoring result " + title + " because we don't want an episode (" + str(cpr.season) + "x" + str(epNo) + ") that is " + Quality.qualityStrings[quality], logger.DEBUG) continue logger.log(u"Found result " + title + " at " + url, logger.DEBUG) # make a result object epObj = [] for curEp in cpr.episodes: epObj.append(show.getEpisode(cpr.season, curEp)) result = self.getResult(epObj) result.url = url result.name = title result.quality = cpr.quality if len(epObj) == 1: epNum = epObj[0].episode elif len(epObj) > 1: epNum = MULTI_EP_RESULT logger.log(u"Separating multi-episode result to check for later - result contains episodes: " + str(parse_result.episode_numbers), logger.DEBUG) elif len(epObj) == 0: epNum = SEASON_RESULT result.extraInfo = [show] logger.log(u"Separating full season result to check for later", logger.DEBUG) if epNum in results: results[epNum].append(result) else: results[epNum] = [result] return results
def _analyze_name(self, name, file=True): """ Takes a name and tries to figure out a show, season, and episode from it. name: A string which we want to analyze to determine show info from (unicode) Returns a (tvdb_id, season, [episodes]) tuple. The first two may be None and episodes may be [] if none were found. """ logger.log(u"Analyzing name " + repr(name)) to_return = (None, None, []) if not name: return to_return cp = CompleteParser(log=self._log, tvdbActiveLookUp=True) cpr = cp.parse(name) self.is_proper = cpr.is_proper self.series_name = cpr.series_name return (cpr.tvdbid, cpr.season, cpr.episodes) """ # parse the name to break it into show name, season, and episode np = NameParser(file) parse_result = np.parse(name) self._log("Parsed " + name + " into " + str(parse_result).decode('utf-8'), logger.DEBUG) if parse_result.air_by_date: season = -1 episodes = [parse_result.air_date] else: season = parse_result.season_number episodes = parse_result.episode_numbers to_return = (None, season, episodes) # do a scene reverse-lookup to get a list of all possible names name_list = show_name_helpers.sceneToNormalShowNames(parse_result.series_name) if not name_list: return (None, season, episodes) """ def _finalize(parse_result): self.release_group = parse_result.release_group # remember whether it's a proper if parse_result.extra_info: self.is_proper = re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info, re.I) != None # if the result is complete then remember that for later if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group: test_name = os.path.basename(name) if test_name == self.nzb_name: self.good_results[self.NZB_NAME] = True elif test_name == self.folder_name: self.good_results[self.FOLDER_NAME] = True elif test_name == self.file_name: self.good_results[self.FILE_NAME] = True else: logger.log(u"Nothing was good, found " + repr(test_name) + " and wanted either " + repr(self.nzb_name) + ", " + repr(self.folder_name) + ", or " + repr(self.file_name)) else: logger.log(u"Parse result not sufficient(all following have to be set). Will not save release name", logger.DEBUG) logger.log(u"Parse result(series_name): " + str(parse_result.series_name), logger.DEBUG) logger.log(u"Parse result(season_number): " + str(parse_result.season_number), logger.DEBUG) logger.log(u"Parse result(episode_numbers): " + str(parse_result.episode_numbers), logger.DEBUG) logger.log(u"Parse result(release_group): " + str(parse_result.release_group), logger.DEBUG) # for each possible interpretation of that scene name for cur_name in name_list: self._log(u"Checking scene exceptions for a match on " + cur_name, logger.DEBUG) scene_id = scene_exceptions.get_scene_exception_by_name(cur_name) if scene_id: self._log(u"Scene exception lookup got tvdb id " + str(scene_id) + u", using that", logger.DEBUG) _finalize(parse_result) return (scene_id, season, episodes) # see if we can find the name directly in the DB, if so use it for cur_name in name_list: self._log(u"Looking up " + cur_name + u" in the DB", logger.DEBUG) db_result = helpers.searchDBForShow(cur_name) if db_result: self._log(u"Lookup successful, using tvdb id " + str(db_result[0]), logger.DEBUG) _finalize(parse_result) return (int(db_result[0]), season, episodes) # see if we can find the name with a TVDB lookup for cur_name in name_list: try: t = tvdb_api.Tvdb(custom_ui=classes.ShowListUI, **sickbeard.TVDB_API_PARMS) self._log(u"Looking up name " + cur_name + u" on TVDB", logger.DEBUG) showObj = t[cur_name] except (tvdb_exceptions.tvdb_exception): # if none found, search on all languages try: # There's gotta be a better way of doing this but we don't wanna # change the language value elsewhere ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy() ltvdb_api_parms['search_all_languages'] = True t = tvdb_api.Tvdb(custom_ui=classes.ShowListUI, **ltvdb_api_parms) self._log(u"Looking up name " + cur_name + u" in all languages on TVDB", logger.DEBUG) showObj = t[cur_name] except (tvdb_exceptions.tvdb_exception, IOError): pass continue except (IOError): continue self._log(u"Lookup successful, using tvdb id " + str(showObj["id"]), logger.DEBUG) _finalize(parse_result) return (int(showObj["id"]), season, episodes) _finalize(parse_result) return to_return
def _getProperList(self): propers = {} # for each provider get a list of the propers for curProvider in providers.sortedProviderList(): if not curProvider.isActive(): continue date = datetime.datetime.today() - datetime.timedelta(days=2) logger.log(u"Searching for any new PROPER releases from "+curProvider.name) curPropers = curProvider.findPropers(date) # if they haven't been added by a different provider than add the proper to the list for x in curPropers: name = self._genericName(x.name) if not name in propers: logger.log(u"Found new proper: "+x.name, logger.DEBUG) x.provider = curProvider propers[name] = x # take the list of unique propers and get it sorted by sortedPropers = sorted(propers.values(), key=operator.attrgetter('date'), reverse=True) finalPropers = [] for curProper in sortedPropers: # parse the file name cp = CompleteParser() cpr = cp.parse(curProper.name) parse_result = cpr.parse_result if not parse_result.episode_numbers and not parse_result.is_anime: logger.log(u"Ignoring "+curProper.name+" because it's for a full season rather than specific episode", logger.DEBUG) continue # populate our Proper instance if parse_result.air_by_date: curProper.season = -1 curProper.episode = parse_result.air_date else: curProper.season = parse_result.season_number if parse_result.season_number != None else 1 if parse_result.is_anime: logger.log(u"I am sorry '"+curProper.name+"' seams to be an anime proper seach is not yet suported", logger.DEBUG) continue curProper.episode = parse_result.ab_episode_numbers[0] else: curProper.episode = parse_result.episode_numbers[0] curProper.quality = Quality.nameQuality(curProper.name,parse_result.is_anime) # for each show in our list for curShow in sickbeard.showList: genericName = self._genericName(parse_result.series_name) # get the scene name masks sceneNames = set(show_name_helpers.makeSceneShowSearchStrings(curShow)) # for each scene name mask for curSceneName in sceneNames: # if it matches if genericName == self._genericName(curSceneName): logger.log(u"Successful match! Result "+parse_result.series_name+" matched to show "+curShow.name, logger.DEBUG) # set the tvdbid in the db to the show's tvdbid curProper.tvdbid = curShow.tvdbid # since we found it, break out break # if we found something in the inner for loop break out of this one if curProper.tvdbid != -1: break if curProper.tvdbid == -1: continue if not show_name_helpers.filterBadReleases(curProper.name): logger.log(u"Proper "+curProper.name+" isn't a valid scene release that we want, igoring it", logger.DEBUG) continue # if we have an air-by-date show then get the real season/episode numbers if curProper.season == -1 and curProper.tvdbid: showObj = helpers.findCertainShow(sickbeard.showList, curProper.tvdbid) if not showObj: logger.log(u"This should never have happened, post a bug about this!", logger.ERROR) raise Exception("BAD STUFF HAPPENED") tvdb_lang = showObj.lang # There's gotta be a better way of doing this but we don't wanna # change the language value elsewhere ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy() if tvdb_lang and not tvdb_lang == 'en': ltvdb_api_parms['language'] = tvdb_lang try: t = tvdb_api.Tvdb(**ltvdb_api_parms) epObj = t[curProper.tvdbid].airedOn(curProper.episode)[0] curProper.season = int(epObj["seasonnumber"]) curProper.episodes = [int(epObj["episodenumber"])] except tvdb_exceptions.tvdb_episodenotfound: logger.log(u"Unable to find episode with date "+str(curProper.episode)+" for show "+parse_result.series_name+", skipping", logger.WARNING) continue # check if we actually want this proper (if it's the right quality) sqlResults = db.DBConnection().select("SELECT status FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?", [curProper.tvdbid, curProper.season, curProper.episode]) if not sqlResults: continue oldStatus, oldQuality = Quality.splitCompositeStatus(int(sqlResults[0]["status"])) # only keep the proper if we have already retrieved the same quality ep (don't get better/worse ones) if oldStatus not in (DOWNLOADED, SNATCHED) or oldQuality != curProper.quality: continue # if the show is in our list and there hasn't been a proper already added for that particular episode then add it to our list of propers if curProper.tvdbid != -1 and (curProper.tvdbid, curProper.season, curProper.episode) not in map(operator.attrgetter('tvdbid', 'season', 'episode'), finalPropers): logger.log(u"Found a proper that we need: "+str(curProper.name)) finalPropers.append(curProper) return finalPropers
def findEpisode(self, episode, manualSearch=False): logger.log(u"Searching " + self.name + " for " + episode.prettyName()) self.cache.updateCache() results = self.cache.searchCache(episode, manualSearch) logger.log(u"Cache results: " + str(results), logger.DEBUG) # if we got some results then use them no matter what. # OR # return anyway unless we're doing a manual search if results or not manualSearch: return results itemList = [] for cur_search_string in self._get_episode_search_strings(episode): itemList += self._doSearch(cur_search_string, show=episode.show) for item in itemList: (title, url) = self._get_title_and_url(item) """ # parse the file name try: myParser = NameParser() parse_result = myParser.parse(title) except InvalidNameException: logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING) continue """ cp = CompleteParser(show=episode.show, tvdbActiveLookUp=True) cpr = cp.parse(title) parse_result = cpr.parse_result if episode.show.air_by_date: if parse_result.air_date != episode.airdate: logger.log(u"Episode " + title + " didn't air on " + str(episode.airdate) + ", skipping it", logger.DEBUG) continue elif parse_result.season_number != episode.scene_season or episode.scene_episode not in parse_result.episode_numbers: logger.log(u"Episode " + title + " isn't " + str(episode.season) + "x" + str(episode.episode) + ", skipping it", logger.DEBUG) continue quality = cpr.quality #self.getQuality(item) if not episode.show.wantEpisode(episode.season, episode.episode, quality, manualSearch): logger.log(u"Ignoring result " + title + " because we don't want an episode that is " + Quality.qualityStrings[quality], logger.DEBUG) continue logger.log(u"Found result " + title + " at " + url, logger.DEBUG) result = self.getResult([episode]) result.url = url result.name = title result.quality = quality results.append(result) return results
def findEpisode(self, episode, manualSearch=False, searchString=None): self._checkAuth() if searchString: logger.log(u"Searching " + self.name + " for '" + ek.ek(str, searchString) + "'") else: logger.log(u"Searching " + self.name + " for episode " + episode.prettyName(True)) logger.log(u"Searching " + self.name + " for " + episode.prettyName()) self.cache.updateCache() results = self.cache.searchCache(episode, manualSearch) logger.log(u"Cache results: " + str(results), logger.DEBUG) # if we got some results then use them no matter what. # OR # return anyway unless we're doing a manual search if results or not manualSearch: return results if searchString: # if we already got a searchstring don't bother make one search_strings = [searchString] else: search_strings = self._get_episode_search_strings(episode) itemList = [] for cur_search_string in search_strings: itemList += self._doSearch(cur_search_string, show=episode.show) for item in itemList: (title, url) = self._get_title_and_url(item) cp = CompleteParser(show=episode.show, tvdbActiveLookUp=True) cpr = cp.parse(title) parse_result = cpr.parse_result if episode.show.air_by_date: if parse_result.air_date != episode.airdate: logger.log( "Episode " + title + " didn't air on " + str(episode.airdate) + ", skipping it", logger.DEBUG) continue elif cpr.season != episode.season or episode.episode not in cpr.episodes: logger.log( "Episode " + title + " isn't " + str(episode.scene_season) + "x" + str(episode.scene_episode) + " (beware of scene conversion) , skipping it", logger.DEBUG) continue if not episode.show.wantEpisode(episode.season, episode.episode, cpr.quality, manualSearch): logger.log( u"Ignoring result " + title + " because we don't want an episode that is " + Quality.qualityStrings[cpr.quality], logger.DEBUG) continue logger.log(u"Found result " + title + " at " + url, logger.DEBUG) result = self.getResult([episode]) result.url = url result.name = title result.quality = cpr.quality result.release_group = parse_result.release_group result.is_proper = cpr.is_proper results.append(result) return results
def findEpisode (self, episode, manualSearch=False, searchString=None): self._checkAuth() if searchString: logger.log(u"Searching "+self.name+" for '" + ek.ek(str, searchString) + "'") else: logger.log(u"Searching "+self.name+" for episode " + episode.prettyName(True)) logger.log(u"Searching "+self.name+" for " + episode.prettyName()) self.cache.updateCache() results = self.cache.searchCache(episode, manualSearch) logger.log(u"Cache results: "+str(results), logger.DEBUG) # if we got some results then use them no matter what. # OR # return anyway unless we're doing a manual search if results or not manualSearch: return results if searchString: # if we already got a searchstring don't bother make one search_strings = [searchString] else: search_strings = self._get_episode_search_strings(episode) itemList = [] for cur_search_string in search_strings: itemList += self._doSearch(cur_search_string, show=episode.show) for item in itemList: (title, url) = self._get_title_and_url(item) cp = CompleteParser(show=episode.show, tvdbActiveLookUp=True) cpr = cp.parse(title) parse_result = cpr.parse_result if episode.show.air_by_date: if parse_result.air_date != episode.airdate: logger.log("Episode " + title + " didn't air on " + str(episode.airdate) + ", skipping it", logger.DEBUG) continue elif cpr.season != episode.season or episode.episode not in cpr.episodes: logger.log("Episode " + title + " isn't " + str(episode.scene_season) + "x" + str(episode.scene_episode) + " (beware of scene conversion) , skipping it", logger.DEBUG) continue if not episode.show.wantEpisode(episode.season, episode.episode, cpr.quality, manualSearch): logger.log(u"Ignoring result " + title + " because we don't want an episode that is " + Quality.qualityStrings[cpr.quality], logger.DEBUG) continue logger.log(u"Found result " + title + " at " + url, logger.DEBUG) result = self.getResult([episode]) result.url = url result.name = title result.quality = cpr.quality result.release_group = parse_result.release_group result.is_proper = cpr.is_proper results.append(result) return results