From dbaf9955cb03b4b1cf1bec6b50293c14fd0f8925 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 18 Mar 2014 06:50:13 -0700 Subject: [PATCH] Fixed issue with BTN provider. Started to added in "archive on firstmatch" feature. --- gui/slick/interfaces/default/displayShow.tmpl | 6 +++++- .../interfaces/default/inc_qualityChooser.tmpl | 4 ++++ sickbeard/databases/mainDB.py | 13 ++++++++++++- sickbeard/helpers.py | 2 -- sickbeard/postProcessor.py | 2 ++ sickbeard/providers/btn.py | 2 +- sickbeard/tv.py | 8 +++++++- sickbeard/webserve.py | 4 +++- 8 files changed, 34 insertions(+), 7 deletions(-) diff --git a/gui/slick/interfaces/default/displayShow.tmpl b/gui/slick/interfaces/default/displayShow.tmpl index 4fd52ef0..af4df869 100644 --- a/gui/slick/interfaces/default/displayShow.tmpl +++ b/gui/slick/interfaces/default/displayShow.tmpl @@ -160,7 +160,11 @@ Flat Folders: \"Y" Paused: \"Y" Air-by-Date: \"Y" -#if $all_scene_exceptions: + DVD Order: \"Y" +#if $bestQualities + Archive First Match: \"Y" +#end if +#if $all_scene_exceptions: Alternate Scene Names: diff --git a/gui/slick/interfaces/default/inc_qualityChooser.tmpl b/gui/slick/interfaces/default/inc_qualityChooser.tmpl index 6a0e91e6..5971b1ff 100644 --- a/gui/slick/interfaces/default/inc_qualityChooser.tmpl +++ b/gui/slick/interfaces/default/inc_qualityChooser.tmpl @@ -44,4 +44,8 @@ + Archive on first match: +
+ (check this to have the show archived after first match and download from your archive quality choices) +
diff --git a/sickbeard/databases/mainDB.py b/sickbeard/databases/mainDB.py index 9744aa1c..9865bb9f 100644 --- a/sickbeard/databases/mainDB.py +++ b/sickbeard/databases/mainDB.py @@ -27,7 +27,7 @@ from sickbeard import encodingKludge as ek from sickbeard.name_parser.parser import NameParser, InvalidNameException MIN_DB_VERSION = 9 # oldest db version we support migrating from -MAX_DB_VERSION = 25 +MAX_DB_VERSION = 26 class MainSanityCheck(db.DBSanityCheck): @@ -559,4 +559,15 @@ class ConvertInfoToIndexerScheme(ConvertIMDBInfoToIndexerScheme): self.connection.action("INSERT INTO info(last_backlog, last_indexer, last_proper_search) SELECT last_backlog, last_tvdb, last_proper_search FROM tmp_info") self.connection.action("DROP TABLE tmp_info") + self.incDBVersion() + +class AddArchiveFirstMatchOption(ConvertInfoToIndexerScheme): + def test(self): + return self.checkDBVersion() >= 26 + + def execute(self): + backupDatabase(26) + + self.connection.action("ALTER TABLE tv_shows ADD archive_firstmatch NUMERIC") + self.incDBVersion() \ No newline at end of file diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 0cf26f8c..b740372f 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -306,8 +306,6 @@ def searchIndexersForShow(regShowName): showNames = [re.sub('[. -]', ' ', regShowName),regShowName] - yearRegex = "([^()]+?)\s*(\()?(\d{4})(?(2)\))$" - for name in showNames: for indexer in indexerStrings: logger.log(u"Trying to find the " + name + " on " + indexer, logger.DEBUG) diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 57639139..8eb6721f 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -741,6 +741,7 @@ class PostProcessor(object): logger.log(self.file_name + u" looks like it has quality " + common.Quality.qualityStrings[ep_quality] + ", using that", logger.DEBUG) return ep_quality + test = str(ep_quality) return ep_quality def _run_extra_scripts(self, ep_obj): @@ -845,6 +846,7 @@ class PostProcessor(object): # get the quality of the episode we're processing new_ep_quality = self._get_quality(ep_obj) + test = str(new_ep_quality) logger.log(u"Quality of the episode we're processing: " + str(new_ep_quality), logger.DEBUG) # see if this is a priority download (is it snatched, in history, or PROPER) diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index e8c4b67f..c5efe90a 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -237,7 +237,7 @@ class BTNProvider(generic.TorrentProvider): search_params = {'category': 'Episode'} - search_params['series'] = sanitizeSceneName(ep_obj.show_name) + search_params['series'] = sanitizeSceneName(ep_obj.show.name) if ep_obj.show.air_by_date: date_str = str(ep_obj.airdate) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 409c9f5f..76164d13 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -78,6 +78,7 @@ class TVShow(object): self.air_by_date = 0 self.subtitles = int(sickbeard.SUBTITLES_DEFAULT if sickbeard.SUBTITLES_DEFAULT else 0) self.dvdorder = 0 + self.archive_firstmatch = 0 self.lang = lang self.last_update_indexer = 1 @@ -662,6 +663,10 @@ class TVShow(object): if not self.dvdorder: self.dvdorder = 0 + self.archive_firstmatch = sqlResults[0]["archive_firstmatch"] + if not self.archive_firstmatch: + self.archive_firstmatch = 0 + self.quality = int(sqlResults[0]["quality"]) self.flatten_folders = int(sqlResults[0]["flatten_folders"]) self.paused = int(sqlResults[0]["paused"]) @@ -924,6 +929,7 @@ class TVShow(object): "air_by_date": self.air_by_date, "subtitles": self.subtitles, "dvdorder": self.dvdorder, + "archive_firstmatch": self.archive_firstmatch, "startyear": self.startyear, "lang": self.lang, "imdb_id": self.imdbid, @@ -982,7 +988,7 @@ class TVShow(object): # if we know we don't want it then just say no if epStatus in (SKIPPED, IGNORED, ARCHIVED) and not manualSearch: - logger.log(u"Ep is skipped, not bothering", logger.DEBUG) + logger.log(u"Ep is skipped or marked as archived, not bothering", logger.DEBUG) return False # if it's one of these then we want it as long as it's in our allowed initial qualities diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index f9e8729c..62e6d855 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -2805,7 +2805,7 @@ class Home: return result['description'] if result else 'Episode not found.' @cherrypy.expose - def editShow(self, show=None, location=None, anyQualities=[], bestQualities=[], exceptions_list=[], flatten_folders=None, paused=None, directCall=False, air_by_date=None, dvdorder=None, indexerLang=None, subtitles=None): + def editShow(self, show=None, location=None, anyQualities=[], bestQualities=[], exceptions_list=[], flatten_folders=None, paused=None, directCall=False, air_by_date=None, dvdorder=None, indexerLang=None, subtitles=None, archive_firstmatch=None): if show == None: errString = "Invalid show ID: " + str(show) @@ -2840,6 +2840,7 @@ class Home: logger.log(u"flatten folders: " + str(flatten_folders)) dvdorder = config.checkbox_to_value(dvdorder) + archive_firstmatch = config.checkbox_to_value(archive_firstmatch) paused = config.checkbox_to_value(paused) air_by_date = config.checkbox_to_value(air_by_date) subtitles = config.checkbox_to_value(subtitles) @@ -2888,6 +2889,7 @@ class Home: showObj.subtitles = subtitles showObj.lang = indexer_lang showObj.dvdorder = dvdorder + showObj.archive_firstmatch = archive_firstmatch # if we change location clear the db of episodes, change it, write to db, and rescan if os.path.normpath(showObj._location) != os.path.normpath(location):