diff --git a/gui/slick/views/config_general.mako b/gui/slick/views/config_general.mako index 0f792f56b71368ab036546b4a7df79f0cf8cb23c..feb4cbffe73fcc2c410226addc1e4ba2a1bf576c 100644 --- a/gui/slick/views/config_general.mako +++ b/gui/slick/views/config_general.mako @@ -750,17 +750,6 @@ </span> </label> </div> - - <div class="field-pair" hidden> - <label for="git_autoissues"> - <span class="component-title">Git auto-issues submit</span> - <span class="component-desc"> - <input type="checkbox" name="git_autoissues" id="git_autoissues" ${('', 'checked="checked"')[bool(sickbeard.GIT_AUTOISSUES)]} disable/> - <p>automatically submit bug/issue reports to our issue tracker when errors are logged</p> - </span> - </label> - </div> - <input type="submit" class="btn config_submitter" value="Save Changes" /> </fieldset> diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 98224fc0078606b1bb2b697c540b75b7d1c43556..6e6edb08b40d70adebd0da02c7da196b5246ea1e 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -137,7 +137,6 @@ GIT_REPO = 'SickRage' GIT_USERNAME = None GIT_PASSWORD = None GIT_PATH = None -GIT_AUTOISSUES = False DEVELOPER = False NEWS_URL = 'http://sickrage.github.io/sickrage-news/news.md' @@ -622,7 +621,7 @@ def initialize(consoleLogging=True): AUTOPOSTPROCESSER_FREQUENCY, SHOWUPDATE_HOUR, \ ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \ ANIME_SPLIT_HOME, SCENE_DEFAULT, DOWNLOAD_URL, BACKLOG_DAYS, GIT_USERNAME, GIT_PASSWORD, \ - GIT_AUTOISSUES, DEVELOPER, gh, DISPLAY_ALL_SEASONS, SSL_VERIFY, NEWS_LAST_READ, NEWS_LATEST, SOCKET_TIMEOUT + DEVELOPER, gh, DISPLAY_ALL_SEASONS, SSL_VERIFY, NEWS_LAST_READ, NEWS_LATEST, SOCKET_TIMEOUT if __INITIALIZED__: return False @@ -654,8 +653,6 @@ def initialize(consoleLogging=True): ENCRYPTION_VERSION = check_setting_int(CFG, 'General', 'encryption_version', 0) ENCRYPTION_SECRET = check_setting_str(CFG, 'General', 'encryption_secret', helpers.generateCookieSecret(), censor_log=True) - GIT_AUTOISSUES = bool(check_setting_int(CFG, 'General', 'git_autoissues', 0)) - # git login info GIT_USERNAME = check_setting_str(CFG, 'General', 'git_username', '') GIT_PASSWORD = check_setting_str(CFG, 'General', 'git_password', '', censor_log=True) @@ -1601,7 +1598,6 @@ def save_config(): # For passwords you must include the word `password` in the item_name and add `helpers.encrypt(ITEM_NAME, ENCRYPTION_VERSION)` in save_config() new_config['General'] = {} - new_config['General']['git_autoissues'] = int(GIT_AUTOISSUES) new_config['General']['git_username'] = GIT_USERNAME new_config['General']['git_password'] = helpers.encrypt(GIT_PASSWORD, ENCRYPTION_VERSION) new_config['General']['git_reset'] = int(GIT_RESET) diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 56fb098e151c818ec40c9f5f180cb93c1e41bde2..2c20fc430a3ae8b51ca78dbc74ba6320bd949ad6 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -160,8 +160,8 @@ class Logger(object): # pylint: disable=too-many-instance-attributes message = meThread + u" :: " + msg # Change the SSL error to a warning with a link to information about how to fix it. - check = re.sub(ur'error \[Errno 1\] _ssl.c:\d{3}: error:\d{8}:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error', 'See: http://git.io/vJrkM', message) - if check is not message: + check = re.sub(ur'error \[Errno 1\] _ssl.c:\d{3}: error:\d{8}:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error', 'See: http://git.io/vuU5V', message) + if check != message: message = check level = WARNING @@ -170,9 +170,6 @@ class Logger(object): # pylint: disable=too-many-instance-attributes elif level == WARNING: classes.WarningViewer.add(classes.UIError(message)) - # if sickbeard.GIT_AUTOISSUES: - # self.submit_errors() - if level == ERROR: self.logger.exception(message, *args, **kwargs) else: @@ -186,7 +183,7 @@ class Logger(object): # pylint: disable=too-many-instance-attributes else: sys.exit(1) - def submit_errors(self): # Too many local variables, too many branches, pylint: disable=too-many-branches,too-many-locals + def submit_errors(self): # pylint: disable=too-many-branches,too-many-locals submitter_result = u'' issue_id = None diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 2146c5471f586e1c0399c077d580b339c7b5302a..e88dc1e2501a69ca515ec0d214a1b1f5e5c3621e 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -16,6 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with SickRage. If not, see <http://www.gnu.org/licenses/>. +# pylint: disable=too-many-lines import os.path import datetime @@ -77,7 +78,7 @@ def dirty_setter(attr_name): return wrapper -class TVShow(object): +class TVShow(object): # pylint: disable=too-many-instance-attributes, too-many-public-methods def __init__(self, indexer, indexerid, lang=""): self._indexerid = int(indexerid) self._indexer = int(indexer) @@ -231,7 +232,7 @@ class TVShow(object): return ep_list - def getEpisode(self, season=None, episode=None, file=None, noCreate=False, absolute_number=None, forceUpdate=False): + def getEpisode(self, season=None, episode=None, file=None, noCreate=False, absolute_number=None): # pylint: disable=too-many-arguments season = try_int(season, None) episode = try_int(episode, None) absolute_number = try_int(absolute_number, None) @@ -449,7 +450,7 @@ class TVShow(object): myDB = db.DBConnection() myDB.mass_action(sql_l) - def loadEpisodesFromDB(self): + def loadEpisodesFromDB(self): # pylint: disable=too-many-locals logger.log(u"Loading all episodes from the DB", logger.DEBUG) scannedEps = {} @@ -590,7 +591,7 @@ class TVShow(object): return scannedEps - def getImages(self, fanart=None, poster=None): + def getImages(self): fanart_result = poster_result = banner_result = False season_posters_result = season_banners_result = season_all_poster_result = season_all_banner_result = False @@ -610,7 +611,7 @@ class TVShow(object): return fanart_result or poster_result or banner_result or season_posters_result or season_banners_result or season_all_poster_result or season_all_banner_result # make a TVEpisode object from a media file - def makeEpFromFile(self, file): + def makeEpFromFile(self, file): # pylint: disable=too-many-locals, too-many-branches, too-many-statements if not ek(os.path.isfile, file): logger.log(str(self.indexerid) + u": That isn't even a real file dude... " + file) @@ -727,9 +728,8 @@ class TVShow(object): if newStatus is not None: with curEp.lock: - logger.log(u"STATUS: we have an associated file, so setting the status from " + str( - curEp.status) + u" to DOWNLOADED/" + str(Quality.statusFromName(file, anime=self.is_anime)), - logger.DEBUG) + logger.log(u"STATUS: we have an associated file, so setting the status from %s to DOWNLOADED/%s" % (curEp.status, Quality.statusFromName(file, anime=self.is_anime)), + logger.DEBUG) curEp.status = Quality.compositeStatus(newStatus, newQuality) with curEp.lock: @@ -746,7 +746,7 @@ class TVShow(object): return rootEp - def loadFromDB(self, skipNFO=False): + def loadFromDB(self): # pylint: disable=too-many-branches, too-many-statements logger.log(str(self.indexerid) + u": Loading show info from database", logger.DEBUG) @@ -825,131 +825,135 @@ class TVShow(object): self.dirty = False return True - def loadFromIndexer(self, cache=True, tvapi=None, cachedSeason=None): + def loadFromIndexer(self, cache=True, tvapi=None): - if self.indexer is not INDEXER_TVRAGE: - logger.log(str(self.indexerid) + u": Loading show info from " + sickbeard.indexerApi(self.indexer).name, logger.DEBUG) - - # There's gotta be a better way of doing this but we don't wanna - # change the cache value elsewhere - if tvapi is None: - lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy() - - if not cache: - lINDEXER_API_PARMS['cache'] = False - - if self.lang: - lINDEXER_API_PARMS['language'] = self.lang - - if self.dvdorder != 0: - lINDEXER_API_PARMS['dvdorder'] = True - - t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS) - - else: - t = tvapi + if self.indexer == INDEXER_TVRAGE: + return - myEp = t[self.indexerid] + logger.log(str(self.indexerid) + u": Loading show info from " + sickbeard.indexerApi(self.indexer).name, logger.DEBUG) - try: - self.name = myEp['seriesname'].strip() - except AttributeError: - raise sickbeard.indexer_attributenotfound( - "Found %s, but attribute 'seriesname' was empty." % self.indexerid) + # There's gotta be a better way of doing this but we don't wanna + # change the cache value elsewhere + if tvapi: + t = tvapi + else: + lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy() - self.classification = getattr(myEp, 'classification', 'Scripted') - self.genre = getattr(myEp, 'genre', '') - self.network = getattr(myEp, 'network', '') - self.runtime = getattr(myEp, 'runtime', '') + if not cache: + lINDEXER_API_PARMS['cache'] = False - self.imdbid = getattr(myEp, 'imdb_id', '') + if self.lang: + lINDEXER_API_PARMS['language'] = self.lang - if getattr(myEp, 'airs_dayofweek', None) is not None and getattr(myEp, 'airs_time', None) is not None: - self.airs = myEp["airs_dayofweek"] + " " + myEp["airs_time"] + if self.dvdorder != 0: + lINDEXER_API_PARMS['dvdorder'] = True - if self.airs is None: - self.airs = '' + t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS) - if getattr(myEp, 'firstaired', None) is not None: - self.startyear = int(str(myEp["firstaired"]).split('-')[0]) + myEp = t[self.indexerid] - self.status = getattr(myEp, 'status', 'Unknown') - else: - logger.log(str(self.indexerid) + u": NOT loading info from " + sickbeard.indexerApi(self.indexer).name + " as it is temporarily disabled.", logger.WARNING) - - def loadIMDbInfo(self, imdbapi=None): - - imdb_info = {'imdb_id': self.imdbid, - 'title': '', - 'year': '', - 'akas': [], - 'runtimes': '', - 'genres': [], - 'countries': '', - 'country_codes': [], - 'certificates': [], - 'rating': '', - 'votes': '', - 'last_update': ''} + try: + self.name = myEp['seriesname'].strip() + except AttributeError: + raise sickbeard.indexer_attributenotfound( + "Found %s, but attribute 'seriesname' was empty." % self.indexerid) + + self.classification = getattr(myEp, 'classification', 'Scripted') + self.genre = getattr(myEp, 'genre', '') + self.network = getattr(myEp, 'network', '') + self.runtime = getattr(myEp, 'runtime', '') + + self.imdbid = getattr(myEp, 'imdb_id', '') + + if getattr(myEp, 'airs_dayofweek', None) is not None and getattr(myEp, 'airs_time', None) is not None: + self.airs = myEp["airs_dayofweek"] + " " + myEp["airs_time"] + + if self.airs is None: + self.airs = '' + + if getattr(myEp, 'firstaired', None) is not None: + self.startyear = int(str(myEp["firstaired"]).split('-')[0]) + + self.status = getattr(myEp, 'status', 'Unknown') + + def loadIMDbInfo(self): # pylint: disable=too-many-branches + + imdb_info = { + 'imdb_id': self.imdbid, + 'title': '', + 'year': '', + 'akas': [], + 'runtimes': '', + 'genres': [], + 'countries': '', + 'country_codes': [], + 'certificates': [], + 'rating': '', + 'votes': '', + 'last_update': '' + } i = imdb.IMDb() if not self.imdbid: self.imdbid = i.title2imdbID(self.name, kind='tv series') - if self.imdbid: - logger.log(str(self.indexerid) + u": Loading show info from IMDb", logger.DEBUG) + if not self.imdbid: + logger.log(str(self.indexerid) + u": Not loading show info from IMDb, because we don't know the imdbid", logger.DEBUG) + return - imdbTv = i.get_movie(str(re.sub(r"[^0-9]", "", self.imdbid))) + logger.log(str(self.indexerid) + u": Loading show info from IMDb", logger.DEBUG) - for key in [x for x in imdb_info.keys() if x.replace('_', ' ') in imdbTv.keys()]: - # Store only the first value for string type - if isinstance(imdb_info[key], basestring) and isinstance(imdbTv.get(key.replace('_', ' ')), list): - imdb_info[key] = imdbTv.get(key.replace('_', ' '))[0] - else: - imdb_info[key] = imdbTv.get(key.replace('_', ' ')) + imdbTv = i.get_movie(str(re.sub(r"[^0-9]", "", self.imdbid))) - # Filter only the value - if imdb_info['runtimes']: - imdb_info['runtimes'] = re.search(r'\d+', imdb_info['runtimes']).group(0) + for key in [x for x in imdb_info.keys() if x.replace('_', ' ') in imdbTv.keys()]: + # Store only the first value for string type + if isinstance(imdb_info[key], basestring) and isinstance(imdbTv.get(key.replace('_', ' ')), list): + imdb_info[key] = imdbTv.get(key.replace('_', ' '))[0] else: - imdb_info['runtimes'] = self.runtime + imdb_info[key] = imdbTv.get(key.replace('_', ' ')) - if imdb_info['akas']: - imdb_info['akas'] = '|'.join(imdb_info['akas']) - else: - imdb_info['akas'] = '' + # Filter only the value + if imdb_info['runtimes']: + imdb_info['runtimes'] = re.search(r'\d+', imdb_info['runtimes']).group(0) + else: + imdb_info['runtimes'] = self.runtime - # Join all genres in a string - if imdb_info['genres']: - imdb_info['genres'] = '|'.join(imdb_info['genres']) - else: - imdb_info['genres'] = '' + if imdb_info['akas']: + imdb_info['akas'] = '|'.join(imdb_info['akas']) + else: + imdb_info['akas'] = '' - # Get only the production country certificate if any - if imdb_info['certificates'] and imdb_info['countries']: - dct = {} - try: - for item in imdb_info['certificates']: - dct[item.split(':')[0]] = item.split(':')[1] + # Join all genres in a string + if imdb_info['genres']: + imdb_info['genres'] = '|'.join(imdb_info['genres']) + else: + imdb_info['genres'] = '' - imdb_info['certificates'] = dct[imdb_info['countries']] - except Exception: - imdb_info['certificates'] = '' + # Get only the production country certificate if any + if imdb_info['certificates'] and imdb_info['countries']: + dct = {} + try: + for item in imdb_info['certificates']: + dct[item.split(':')[0]] = item.split(':')[1] - else: + imdb_info['certificates'] = dct[imdb_info['countries']] + except Exception: imdb_info['certificates'] = '' - if imdb_info['country_codes']: - imdb_info['country_codes'] = '|'.join(imdb_info['country_codes']) - else: - imdb_info['country_codes'] = '' + else: + imdb_info['certificates'] = '' + + if imdb_info['country_codes']: + imdb_info['country_codes'] = '|'.join(imdb_info['country_codes']) + else: + imdb_info['country_codes'] = '' - imdb_info['last_update'] = datetime.date.today().toordinal() + imdb_info['last_update'] = datetime.date.today().toordinal() - # Rename dict keys without spaces for DB upsert - self.imdb_info = dict( - (k.replace(' ', '_'), k(v) if hasattr(v, 'keys') else v) for k, v in imdb_info.iteritems()) - logger.log(str(self.indexerid) + u": Obtained info from IMDb ->" + str(self.imdb_info), logger.DEBUG) + # Rename dict keys without spaces for DB upsert + self.imdb_info = dict( + (k.replace(' ', '_'), k(v) if hasattr(v, 'keys') else v) for k, v in imdb_info.iteritems()) + logger.log(str(self.indexerid) + u": Obtained info from IMDb ->" + str(self.imdb_info), logger.DEBUG) def nextEpisode(self): logger.log(str(self.indexerid) + ": Finding the episode which airs next", logger.DEBUG) @@ -1106,7 +1110,6 @@ class TVShow(object): myDB.mass_action(sql_l) def download_subtitles(self, force=False): - # TODO: Add support for force option if not ek(os.path.isdir, self._location): logger.log(str(self.indexerid) + ": Show dir doesn't exist, can't download subtitles", logger.DEBUG) return @@ -1195,10 +1198,11 @@ class TVShow(object): toReturn += "anime: " + str(self.is_anime) + "\n" return toReturn - def qualitiesToString(self, qualities=None): + @staticmethod + def qualitiesToString(qualities=None): return ', '.join([Quality.qualityStrings[quality] for quality in qualities or [] if quality and quality in Quality.qualityStrings]) or 'None' - def wantEpisode(self, season, episode, quality, manualSearch=False, downCurQuality=False): + def wantEpisode(self, season, episode, quality, manualSearch=False, downCurQuality=False): # pylint: disable=too-many-return-statements, too-many-arguments # if the quality isn't one we want under any circumstances then just say no allowed_qualities, preferred_qualities = Quality.splitQuality(self.quality) @@ -1209,7 +1213,7 @@ class TVShow(object): if quality not in allowed_qualities + preferred_qualities or quality is UNKNOWN: logger.log(u"Don't want this quality, ignoring found result for %s S%02dE%02d with quality %s" % - (self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) + (self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) return False myDB = db.DBConnection() @@ -1218,7 +1222,7 @@ class TVShow(object): if not sqlResults or not len(sqlResults): logger.log(u"Unable to find a matching episode in database, ignoring found result for %s S%02dE%02d with quality %s" % - (self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) + (self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) return False epStatus = int(sqlResults[0]["status"]) @@ -1227,15 +1231,15 @@ class TVShow(object): # if we know we don't want it then just say no if epStatus in Quality.ARCHIVED + [UNAIRED, SKIPPED, IGNORED] and not manualSearch: logger.log(u"Existing episode status is '%s', ignoring found result for %s S%02dE%02d with quality %s" % - (epStatus_text, self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) + (epStatus_text, self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) return False - curStatus, curQuality = Quality.splitCompositeStatus(epStatus) + _, curQuality = Quality.splitCompositeStatus(epStatus) # if it's one of these then we want it as long as it's in our allowed initial qualities if epStatus in (WANTED, SKIPPED, UNKNOWN): logger.log(u"Existing episode status is '%s', getting found result for %s S%02dE%02d with quality %s" % - (epStatus_text, self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) + (epStatus_text, self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) return True elif manualSearch: if (downCurQuality and quality >= curQuality) or (not downCurQuality and quality > curQuality): @@ -1247,18 +1251,18 @@ class TVShow(object): # if we are re-downloading then we only want it if it's in our preferred_qualities list and better than what we have, or we only have one bestQuality and we do not have that quality yet if epStatus in Quality.DOWNLOADED + Quality.SNATCHED + Quality.SNATCHED_PROPER and quality in preferred_qualities and (quality > curQuality or curQuality not in preferred_qualities): logger.log(u"Episode already exists with quality %s but the found result quality %s is wanted more, getting found result for %s S%02dE%02d" % - (Quality.qualityStrings[curQuality], Quality.qualityStrings[quality], self.name, season or 0, episode or 0), logger.DEBUG) + (Quality.qualityStrings[curQuality], Quality.qualityStrings[quality], self.name, season or 0, episode or 0), logger.DEBUG) return True elif curQuality == Quality.UNKNOWN and manualSearch: logger.log(u"Episode already exists but quality is Unknown, getting found result for %s S%02dE%02d with quality %s" % - (self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) + (self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) return True else: logger.log(u"Episode already exists with quality %s and the found result has same/lower quality, ignoring found result for %s S%02dE%02d with quality %s" % - (Quality.qualityStrings[curQuality], self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) + (Quality.qualityStrings[curQuality], self.name, season or 0, episode or 0, Quality.qualityStrings[quality]), logger.DEBUG) return False - def getOverview(self, epStatus): + def getOverview(self, epStatus): # pylint: disable=too-many-return-statements, too-many-branches """ Get the Overview status from the Episode status @@ -1289,13 +1293,7 @@ class TVShow(object): ep_status, cur_quality = Quality.splitCompositeStatus(ep_status) if cur_quality not in allowed_qualities + preferred_qualities: - if cur_quality != Quality.UNKNOWN and ( - (allowed_qualities and cur_quality > max(allowed_qualities)) or - (preferred_qualities and cur_quality > max(preferred_qualities)) - ): - return Overview.GOOD - else: - return Overview.QUAL + return Overview.QUAL elif preferred_qualities and cur_quality not in preferred_qualities: return Overview.QUAL else: @@ -1303,7 +1301,6 @@ class TVShow(object): else: logger.log(u'Could not parse episode status into a valid overview status: %s' % epStatus, logger.ERROR) - def __getstate__(self): d = dict(self.__dict__) del d['lock'] @@ -1314,7 +1311,7 @@ class TVShow(object): self.__dict__.update(d) -class TVEpisode(object): +class TVEpisode(object): # pylint: disable=too-many-instance-attributes, too-many-public-methods def __init__(self, show, season, episode, file=""): self._name = "" self._season = season @@ -1448,13 +1445,13 @@ class TVEpisode(object): if ek(os.path.isfile, self.location): for cur_provider in sickbeard.metadata_provider_dict.values(): if cur_provider.episode_metadata: - new_result = cur_provider._has_episode_metadata(self) + new_result = cur_provider._has_episode_metadata(self) # pylint: disable=protected-access else: new_result = False cur_nfo = new_result or cur_nfo if cur_provider.episode_thumbnails: - new_result = cur_provider._has_episode_thumb(self) + new_result = cur_provider._has_episode_thumb(self) # pylint: disable=protected-access else: new_result = False cur_tbn = new_result or cur_tbn @@ -1488,7 +1485,7 @@ class TVEpisode(object): if not result: raise EpisodeNotFoundException("Couldn't find episode S%02dE%02d" % (season or 0, episode or 0)) - def loadFromDB(self, season, episode): + def loadFromDB(self, season, episode): # pylint: disable=too-many-branches # logger.log(u"%s: Loading episode details for %s S%02dE%02d from DB" % (self.show.indexerid, self.show.name, season or 0, episode or 0), logger.DEBUG) myDB = db.DBConnection() @@ -1565,7 +1562,7 @@ class TVEpisode(object): self.dirty = False return True - def loadFromIndexer(self, season=None, episode=None, cache=True, tvapi=None, cachedSeason=None): + def loadFromIndexer(self, season=None, episode=None, cache=True, tvapi=None, cachedSeason=None): # pylint: disable=too-many-arguments, too-many-branches, too-many-statements if season is None: season = self.season @@ -1578,33 +1575,31 @@ class TVEpisode(object): indexer_lang = self.show.lang try: - if cachedSeason is None: - if tvapi is None: - lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy() + if cachedSeason: + myEp = cachedSeason[episode] + elif tvapi: + t = tvapi + else: + lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy() - if not cache: - lINDEXER_API_PARMS['cache'] = False + if not cache: + lINDEXER_API_PARMS['cache'] = False - if indexer_lang: - lINDEXER_API_PARMS['language'] = indexer_lang + if indexer_lang: + lINDEXER_API_PARMS['language'] = indexer_lang - if self.show.dvdorder != 0: - lINDEXER_API_PARMS['dvdorder'] = True + if self.show.dvdorder != 0: + lINDEXER_API_PARMS['dvdorder'] = True - t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS) - else: - t = tvapi - myEp = t[self.show.indexerid][season][episode] - else: - myEp = cachedSeason[episode] + t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS) + myEp = t[self.show.indexerid][season][episode] except (sickbeard.indexer_error, IOError) as e: logger.log(u"" + sickbeard.indexerApi(self.indexer).name + " threw up an error: " + ex(e), logger.DEBUG) # if the episode is already valid just log it, if not throw it up if self.name: - logger.log(u"" + sickbeard.indexerApi( - self.indexer).name + " timed out but we have enough info from other sources, allowing the error", - logger.DEBUG) + logger.log(u"" + sickbeard.indexerApi(self.indexer).name + + " timed out but we have enough info from other sources, allowing the error", logger.DEBUG) return else: logger.log(u"" + sickbeard.indexerApi(self.indexer).name + " timed out, unable to create the episode", @@ -1621,10 +1616,6 @@ class TVEpisode(object): if getattr(myEp, 'episodename', None) is None: logger.log(u"This episode %s - S%02dE%02d has no name on %s. Setting to an empty string" % (self.show.name, season or 0, episode or 0, sickbeard.indexerApi(self.indexer).name)) setattr(myEp, 'episodename', '') - # # if I'm incomplete on TVDB but I once was complete then just delete myself from the DB for now - # if self.indexerid != -1: - # self.deleteEpisode() - # return False if getattr(myEp, 'absolute_number', None) is None: logger.log(u"%s: This episode %s - S%02dE%02d has no absolute number on %s" % (self.show.indexerid, self.show.name, season or 0, episode or 0, sickbeard.indexerApi(self.indexer).name), logger.DEBUG) @@ -1675,8 +1666,8 @@ class TVEpisode(object): return False # don't update show status if show dir is missing, unless it's missing on purpose - if not ek(os.path.isdir, self.show._location) and not sickbeard.CREATE_MISSING_SHOW_DIRS and not sickbeard.ADD_SHOWS_WO_DIR: - logger.log(u"The show dir %s is missing, not bothering to change the episode statuses since it'd probably be invalid" % self.show._location) + if not ek(os.path.isdir, self.show._location) and not sickbeard.CREATE_MISSING_SHOW_DIRS and not sickbeard.ADD_SHOWS_WO_DIR: # pylint: disable=protected-access + logger.log(u"The show dir %s is missing, not bothering to change the episode statuses since it'd probably be invalid" % self.show._location) # pylint: disable=protected-access return if self.location: @@ -1708,9 +1699,9 @@ class TVEpisode(object): logger.log(u"6 Status changes from " + str(self.status) + " to " + str(UNKNOWN), logger.DEBUG) self.status = UNKNOWN - def loadFromNFO(self, location): + def loadFromNFO(self, location): # pylint: disable=too-many-branches - if not ek(os.path.isdir, self.show._location): + if not ek(os.path.isdir, self.show._location): # pylint: disable=protected-access logger.log( str(self.show.indexerid) + u": The show dir is missing, not bothering to try loading the episode NFO") return @@ -1723,11 +1714,10 @@ class TVEpisode(object): if self.location != "": - if self.status == UNKNOWN: - if sickbeard.helpers.isMediaFile(self.location): - logger.log(u"7 Status changes from " + str(self.status) + " to " + str( - Quality.statusFromName(self.location, anime=self.show.is_anime)), logger.DEBUG) - self.status = Quality.statusFromName(self.location, anime=self.show.is_anime) + if self.status == UNKNOWN and sickbeard.helpers.isMediaFile(self.location): + logger.log(u"7 Status changes from " + str(self.status) + " to " + str( + Quality.statusFromName(self.location, anime=self.show.is_anime)), logger.DEBUG) + self.status = Quality.statusFromName(self.location, anime=self.show.is_anime) nfoFile = replace_extension(self.location, "nfo") logger.log(str(self.show.indexerid) + u": Using NFO name " + nfoFile, logger.DEBUG) @@ -1808,7 +1798,7 @@ class TVEpisode(object): def createMetaFiles(self): - if not ek(os.path.isdir, self.show._location): + if not ek(os.path.isdir, self.show._location): # pylint: disable=protected-access logger.log(str(self.show.indexerid) + u": The show dir is missing, not bothering to try to create metadata") return @@ -2040,7 +2030,7 @@ class TVEpisode(object): return goodName - def _replace_map(self): + def _replace_map(self): # pylint: disable=too-many-branches """ Generates a replacement map for this episode which maps all possible custom naming patterns to the correct value for this episode. @@ -2158,7 +2148,8 @@ class TVEpisode(object): '%RT': "PROPER" if self.is_proper else "", } - def _format_string(self, pattern, replace_map): + @staticmethod + def _format_string(pattern, replace_map): """ Replaces all template strings with the correct value """ @@ -2173,7 +2164,7 @@ class TVEpisode(object): return result_name - def _format_pattern(self, pattern=None, multi=None, anime_type=None): + def _format_pattern(self, pattern=None, multi=None, anime_type=None): # pylint: disable=too-many-branches, too-many-statements, too-many-locals """ Manipulates an episode naming pattern and then fills the template in """ @@ -2297,7 +2288,7 @@ class TVEpisode(object): if multi == NAMING_LIMITED_EXTEND_E_PREFIXED: ep_string += 'E' - ep_string += other_ep._format_string(ep_format.upper(), other_ep._replace_map()) + ep_string += other_ep._format_string(ep_format.upper(), other_ep._replace_map()) # pylint: disable=protected-access if anime_type != 3: if self.absolute_number == 0: @@ -2405,7 +2396,7 @@ class TVEpisode(object): return sanitize_filename(self._format_pattern(name_groups[-1], multi, anime_type)) - def rename(self): + def rename(self): # pylint: disable=too-many-locals, too-many-branches """ Renames an episode file and all related files to the location and filename as specified in the naming settings. diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index d160599662f044d4ab976191427316c251697533..e8ec5adb2d8215fb10942a90387d7680507a84f7 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3755,7 +3755,7 @@ class ConfigGeneral(Config): calendar_unprotected=None, calendar_icons=None, debug=None, ssl_verify=None, no_restart=None, coming_eps_missed_range=None, fuzzy_dating=None, trim_zero=None, date_preset=None, date_preset_na=None, time_preset=None, indexer_timeout=None, download_url=None, rootDir=None, theme_name=None, default_page=None, - git_reset=None, git_username=None, git_password=None, git_autoissues=None, display_all_seasons=None): + git_reset=None, git_username=None, git_password=None, display_all_seasons=None): results = [] @@ -3787,7 +3787,6 @@ class ConfigGeneral(Config): # sickbeard.GIT_RESET = config.checkbox_to_value(git_reset) # Force GIT_RESET sickbeard.GIT_RESET = 1 - sickbeard.GIT_AUTOISSUES = config.checkbox_to_value(git_autoissues) sickbeard.GIT_PATH = git_path sickbeard.GIT_REMOTE = git_remote sickbeard.CALENDAR_UNPROTECTED = config.checkbox_to_value(calendar_unprotected) @@ -4516,8 +4515,8 @@ class ConfigProviders(Config): provider_list = provider_list + disabled_list # dynamically load provider settings - for curTorrentProvider in [curProvider for curProvider in sickbeard.providers.sortedProviderList() if - curProvider.provider_type == GenericProvider.TORRENT]: + for curTorrentProvider in [prov for prov in sickbeard.providers.sortedProviderList() if + prov.provider_type == GenericProvider.TORRENT]: if hasattr(curTorrentProvider, 'custom_url'): try: @@ -4667,8 +4666,8 @@ class ConfigProviders(Config): except Exception: curTorrentProvider.subtitle = 0 - for curNzbProvider in [curProvider for curProvider in sickbeard.providers.sortedProviderList() if - curProvider.provider_type == GenericProvider.NZB]: + for curNzbProvider in [prov for prov in sickbeard.providers.sortedProviderList() if + prov.provider_type == GenericProvider.NZB]: if hasattr(curNzbProvider, 'api_key'): try: diff --git a/tests/sickrage_tests/show/show_tests.py b/tests/sickrage_tests/show/show_tests.py index ab53550f74df3e19ee60403ec98af27044d6c335..f28ec0c6b71a3d9297166abb8dcee4bfcd571b81 100644 --- a/tests/sickrage_tests/show/show_tests.py +++ b/tests/sickrage_tests/show/show_tests.py @@ -133,11 +133,9 @@ class TestTVShow(TVShow): def __init__(self, indexer, indexer_id): super(TestTVShow, self).__init__(indexer, indexer_id) - def loadFromDB(self, skip_nfo=False): + def loadFromDB(self): """ Override TVShow.loadFromDB to avoid DB access during testing - - :param skip_nfo: ...not used """ pass diff --git a/tests/tv_tests.py b/tests/tv_tests.py index 810d95c99a7bf0f435a02d8711d44a1168e624dc..1b02e70940040affdf6db4977df94336d4a78a01 100644 --- a/tests/tv_tests.py +++ b/tests/tv_tests.py @@ -66,11 +66,11 @@ class TVShowTests(test.SickbeardTestDBCase): show.startyear = 1987 show.saveToDB() - show.loadFromDB(skipNFO=True) + show.loadFromDB() show.indexerid = 0002 show.saveToDB() - show.loadFromDB(skipNFO=True) + show.loadFromDB() self.assertEqual(show.indexerid, 0002) @@ -81,7 +81,7 @@ class TVShowTests(test.SickbeardTestDBCase): show = TVShow(1, 0001, "en") show.name = "newName" show.saveToDB() - show.loadFromDB(skipNFO=True) + show.loadFromDB() self.assertEqual(show.name, "newName")