diff --git a/gui/slick/views/manage_massEdit.mako b/gui/slick/views/manage_massEdit.mako index d116ecf667883f3b0fa68b47fb126d5f4c354409..720cbe131740633d766b6aad955a4154e01fe876 100644 --- a/gui/slick/views/manage_massEdit.mako +++ b/gui/slick/views/manage_massEdit.mako @@ -6,13 +6,16 @@ from sickbeard.common import Quality, qualityPresets, qualityPresetStrings, statusStrings from sickbeard import exceptions %> -% if quality_value != None: - <% initial_quality = int(quality_value) %> -% else: - <% initial_quality = common.SD %> -% endif -<% anyQualities, bestQualities = common.Quality.splitQuality(initial_quality) %> <%block name="scripts"> +<% + if quality_value != None: + initial_quality = int(quality_value) + else: + initial_quality = common.SD + endif + + anyQualities, bestQualities = common.Quality.splitQuality(initial_quality) +%> <script type="text/javascript" src="${sbRoot}/js/qualityChooser.js?${sbPID}"></script> <script type="text/javascript" src="${sbRoot}/js/massEdit.js?${sbPID}"></script> <script type="text/javascript" charset="utf-8"> @@ -20,6 +23,15 @@ </script> </%block> <%block name="content"> +<% + if quality_value != None: + initial_quality = int(quality_value) + else: + initial_quality = common.SD + endif + + anyQualities, bestQualities = common.Quality.splitQuality(initial_quality) +%> <form action="massEditSubmit" method="post"> <input type="hidden" name="toEdit" value="${showList}" /> diff --git a/gui/slick/views/trendingShows.mako b/gui/slick/views/trendingShows.mako index 6db8fe07f6ac6b50a11e3daf3c74f3af64c56e57..d953abca5648e85a390e4dd1f21c843c901b45d9 100644 --- a/gui/slick/views/trendingShows.mako +++ b/gui/slick/views/trendingShows.mako @@ -66,7 +66,7 @@ $(document).ready(function(){ }); }); </script> -<%block> +</%block> <%block name="content"> <div id="container"> % if not trending_shows: diff --git a/sickbeard/databases/mainDB.py b/sickbeard/databases/mainDB.py index 745350cab666c97fc984bfea4c4608715a29c437..7bf7595897725561131b9fc20351247cc7546264 100644 --- a/sickbeard/databases/mainDB.py +++ b/sickbeard/databases/mainDB.py @@ -46,34 +46,47 @@ class MainSanityCheck(db.DBSanityCheck): self.convert_tvrage_to_tvdb() def convert_tvrage_to_tvdb(self): - logger.log(u'Checking for shows with tvrage id\'s, since tvrage is gone') + logger.log(u"Checking for shows with tvrage id's, since tvrage is gone") from sickbeard.indexers.indexer_config import INDEXER_TVRAGE from sickbeard.indexers.indexer_config import INDEXER_TVDB - sqlResults = self.connection.select( - "SELECT indexer_id, show_name FROM tv_shows WHERE indexer = %i" % INDEXER_TVRAGE) + sqlResults = self.connection.select("SELECT indexer_id, show_name, location FROM tv_shows WHERE indexer = %i" % INDEXER_TVRAGE) if sqlResults: - logger.log(u'Found %i shows with TVRage ID\', FIXING!' % len(sqlResults), logger.WARNING) + logger.log(u"Found %i shows with TVRage ID's, attempting automatic conversion..." % len(sqlResults), logger.WARNING) for tvrage_show in sqlResults: - mapping = self.connection.select( - "SELECT mindexer_id FROM indexer_mapping WHERE indexer_id=%i AND indexer=%i AND mindexer=%i" % - (tvrage_show['indexer_id'], INDEXER_TVRAGE, INDEXER_TVDB) - ) + logger.log(u"Processing %s at %s" % (tvrage_show['show_name'], tvrage_show['location'])) + mapping = self.connection.select("SELECT mindexer_id FROM indexer_mapping WHERE indexer_id=%i AND indexer=%i AND mindexer=%i" % + (tvrage_show['indexer_id'], INDEXER_TVRAGE, INDEXER_TVDB)) if len(mapping) != 1: - logger.log( - u'Error mapping show from tvrage to tvdb for %s, found %i results. This show will no longer update!' % - (tvrage_show['show_name'], len(mapping)), logger.WARNING - ) + logger.log(u"Error mapping show from tvrage to tvdb for %s (%s), found %i mapping results. Cannot convert automatically!" % + (tvrage_show['show_name'], tvrage_show['location'], len(mapping)), logger.WARNING) + logger.log(u"Removing the TVRage show and it's episodes from the DB, use 'addExistingShow'", logger.WARNING) + self.connection.action("DELETE FROM tv_shows WHERE indexer_id = %i AND indexer = %i" % (tvrage_show['indexer_id'], INDEXER_TVRAGE)) + self.connection.action("DELETE FROM tv_episodes WHERE showid = %i" % tvrage_show['indexer_id']) + continue + logger.log(u'Checking if there is already a show with id:%i in the show list') + duplicate = self.connection.select("SELECT * FROM tv_shows WHERE indexer_id = %i AND indexer = %i" % (mapping[0]['mindexer_id'], INDEXER_TVDB)) + if duplicate: + logger.log(u'Found %s which has the same id as %s, cannot convert automatically so I am pausing %s' % + (duplicate[0]['show_name'], tvrage_show['show_name'], duplicate[0]['show_name']), logger.WARNING) + self.connection.action("UPDATE tv_shows SET paused=1 WHERE indexer=%i AND indexer_id=%i" % + (INDEXER_TVDB, duplicate[0]['indexer_id'])) + + logger.log(u"Removing %s and it's episodes from the DB" % tvrage_show['show_name'], logger.WARNING) + self.connection.action("DELETE FROM tv_shows WHERE indexer_id = %i AND indexer = %i" % (tvrage_show['indexer_id'], INDEXER_TVRAGE)) + self.connection.action("DELETE FROM tv_episodes WHERE showid = %i" % tvrage_show['indexer_id']) + logger.log(u'Manually move the season folders from %s into %s, and delete %s before rescanning %s and unpausing it' % + (tvrage_show['location'], duplicate[0]['location'], tvrage_show['location'], duplicate[0]['show_name']), logger.WARNING) continue logger.log('Mapping %s to tvdb id %i' % (tvrage_show['show_name'], mapping[0]['mindexer_id'])) self.connection.action( - "UPDATE OR IGNORE tv_shows SET indexer=%i, indexer_id=%i WHERE indexer_id=%i" % + "UPDATE tv_shows SET indexer=%i, indexer_id=%i WHERE indexer_id=%i" % (INDEXER_TVDB, mapping[0]['mindexer_id'], tvrage_show['indexer_id']) ) diff --git a/sickbeard/providers/tntvillage.py b/sickbeard/providers/tntvillage.py index 3dd782d33f9d74784528a3adf4ef8f54040121dc..501ea167695b83c2b9b9fc570761b54583c31a8b 100644 --- a/sickbeard/providers/tntvillage.py +++ b/sickbeard/providers/tntvillage.py @@ -425,6 +425,17 @@ class TNTVillageProvider(generic.TorrentProvider): logger.log(u"Subtitled, skipping " + title + "(" + searchURL + ")", logger.DEBUG) continue + search_show = re.split(r'([Ss][\d{1,2}]+)', search_string)[0] + show_title = search_show + rindex = re.search(r'([Ss][\d{1,2}]+)', title) + if rindex: + show_title = title[:rindex.start()] + ep_params = title[rindex.start():] + if show_title.lower() != search_show.lower() and search_show.lower() in show_title.lower(): + new_title = search_show + ep_params + logger.log(u"WARNING - Changing found title from: " + title + " to: " + new_title, logger.DEBUG) + title = new_title + if self._is_season_pack(title): title = re.sub(r'([Ee][\d{1,2}\-?]+)', '', title) diff --git a/sickbeard/subtitles.py b/sickbeard/subtitles.py index f741ce655513d6f571a3c39aa5c6041c24dc77a7..1715f3e15444a5008f7fb4be1fb23ed83b378efd 100644 --- a/sickbeard/subtitles.py +++ b/sickbeard/subtitles.py @@ -91,6 +91,9 @@ def subtitlesLanguages(video_path): if sickbeard.SUBTITLES_DIR and ek.ek(os.path.exists, sickbeard.SUBTITLES_DIR): video_path = ek.ek(os.path.join, sickbeard.SUBTITLES_DIR, ek.ek(os.path.basename, video_path)) + # Search subtitles in the relative path + if sickbeard.SUBTITLES_DIR: + video_path = ek.ek(os.path.join, ek.ek(os.path.dirname, video_path), sickbeard.SUBTITLES_DIR, ek.ek(os.path.basename, video_path)) languages = subliminal.video.scan_subtitle_languages(video_path) @@ -220,6 +223,8 @@ def run_subs_extra_scripts(epObj, foundSubs): subpath = subliminal.subtitle.get_subtitle_path(video.name, sub.language) if sickbeard.SUBTITLES_DIR and ek.ek(os.path.exists, sickbeard.SUBTITLES_DIR): subpath = ek.ek(os.path.join, sickbeard.SUBTITLES_DIR, ek.ek(os.path.basename, subpath)) + elif sickbeard.SUBTITLES_DIR: + subpath = ek.ek(os.path.join, ek.ek(os.path.dirname, subpath), sickbeard.SUBTITLES_DIR, ek.ek(os.path.basename, subpath)) inner_cmd = script_cmd + [video.name, subpath, sub.language.opensubtitles, epObj.show.name, str(epObj.season), str(epObj.episode), epObj.name, str(epObj.show.indexerid)] diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 6c09350982efaa36c563c487473a56047d4e1e93..a9ff54bebc74f468ed121b8dcc0bce02d99f3aee 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1456,7 +1456,8 @@ class TVEpisode(object): vname = self.location video = None try: - video = subliminal.scan_video(vname, subtitles=not force, embedded_subtitles=not sickbeard.EMBEDDED_SUBTITLES_ALL or not force) + # Never look for subtitles in the same path, as we specify the path later on + video = subliminal.scan_video(vname, subtitles=False, embedded_subtitles=not sickbeard.EMBEDDED_SUBTITLES_ALL or not force) except Exception: logger.log(u'%s: Exception caught in subliminal.scan_video for S%02dE%02d' % (self.show.indexerid, self.season, self.episode), logger.DEBUG) @@ -1471,15 +1472,26 @@ class TVEpisode(object): logger.log(u'%s: No subtitles found for S%02dE%02d on any provider' % (self.show.indexerid, self.season, self.episode), logger.DEBUG) return - subs_new_path = sickbeard.SUBTITLES_DIR if sickbeard.SUBTITLES_DIR and ek.ek(os.path.exists, sickbeard.SUBTITLES_DIR) else None + # Select the correct subtitles path + if sickbeard.SUBTITLES_DIR and ek.ek(os.path.exists, sickbeard.SUBTITLES_DIR): + subs_new_path = sickbeard.SUBTITLES_DIR + elif sickbeard.SUBTITLES_DIR: + subs_new_path = ek.ek(os.path.join, ek.ek(os.path.dirname, self.location), sickbeard.SUBTITLES_DIR) + dir_exists = helpers.makeDir(subs_new_path) + if not dir_exists: + logger.log(u'Unable to create subtitles folder ' + subs_new_path, logger.ERROR) + else: + helpers.chmodAsParent(subs_new_path) + else: + subs_new_path = ek.ek(os.path.join, ek.ek(os.path.dirname, self.location)) subliminal.save_subtitles(foundSubs, directory=subs_new_path, single=not sickbeard.SUBTITLES_MULTI) for video, subs in foundSubs.iteritems(): for sub in subs: - subpath = subliminal.subtitle.get_subtitle_path(video.name, sub.language if sickbeard.SUBTITLES_MULTI else None) - if sickbeard.SUBTITLES_DIR and ek.ek(os.path.exists, sickbeard.SUBTITLES_DIR): - subpath = ek.ek(os.path.join, sickbeard.SUBTITLES_DIR, ek.ek(os.path.basename, subpath)) + # Get the file name out of video.name and use the path from above + video_path = subs_new_path + "/" + video.name.rsplit("/", 1)[-1] + subpath = subliminal.subtitle.get_subtitle_path(video_path, sub.language if sickbeard.SUBTITLES_MULTI else None) helpers.chmodAsParent(subpath) helpers.fixSetGroupID(subpath) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 7c65a2024e4f437cc038b72465a955db6c281730..22d03b213e62dc5538395a08624c0c9ec4b6bcd5 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -2468,7 +2468,7 @@ class HomeAddShows(Home): posts them to addNewShow """ t = PageTemplate(rh=self, file="home_trendingShows.mako") - return t.render(submenu=self.HomeMenu(), enable_anime_options=False) + return t.render(title="Trending Shows", header="Trending Shows", submenu=self.HomeMenu(), enable_anime_options=False) def getTrendingShows(self): """