diff --git a/sickbeard/metadata/generic.py b/sickbeard/metadata/generic.py index c68fd6a1..636cfb89 100644 --- a/sickbeard/metadata/generic.py +++ b/sickbeard/metadata/generic.py @@ -260,19 +260,55 @@ class GenericMetadata(): """ return None - def create_show_metadata(self, show_obj, force=False): - if self.show_metadata and show_obj and (not self._has_show_metadata(show_obj) or force): + def create_show_metadata(self, show_obj): + if self.show_metadata and show_obj and not self._has_show_metadata(show_obj): logger.log(u"Metadata provider " + self.name + " creating show metadata for " + show_obj.name, logger.DEBUG) return self.write_show_file(show_obj) return False - def create_episode_metadata(self, ep_obj, force=False): - if self.episode_metadata and ep_obj and (not self._has_episode_metadata(ep_obj) or force): + def create_episode_metadata(self, ep_obj): + if self.episode_metadata and ep_obj and not self._has_episode_metadata(ep_obj): logger.log(u"Metadata provider " + self.name + " creating episode metadata for " + ep_obj.prettyName(), logger.DEBUG) return self.write_ep_file(ep_obj) return False + def update_show_indexer_metadata(self, show_obj): + if self.show_metadata and show_obj and self._has_show_metadata(show_obj): + logger.log(u"Metadata provider " + self.name + " updating show indexer info metadata file for " + show_obj.name, logger.DEBUG) + + nfo_file_path = self.get_show_file_path(show_obj) + try: + with ek.ek(open, nfo_file_path, 'r') as xmlFileObj: + showXML = etree.ElementTree(file=xmlFileObj) + + + indexer = showXML.find('indexer') + indexerid = showXML.find('id') + + root = showXML.getroot() + if indexer: + indexer.text = show_obj.indexer + else: + etree.SubElement(root, "indexer").text = str(show_obj.indexer) + + if indexerid: + indexerid.text = show_obj.indexerid + else: + etree.SubElement(root, "id").text = str(show_obj.indexerid) + + # Make it purdy + helpers.indentXML(root) + + showXML.write(nfo_file_path) + helpers.chmodAsParent(nfo_file_path) + + return True + except IOError, e: + logger.log( + u"Unable to write file to " + nfo_file_path + " - are you sure the folder is writable? " + ex(e), + logger.ERROR) + def create_fanart(self, show_obj): if self.fanart and show_obj and not self._has_fanart(show_obj): logger.log(u"Metadata provider " + self.name + " creating fanart for " + show_obj.name, logger.DEBUG) diff --git a/sickbeard/metadata/ps3.py b/sickbeard/metadata/ps3.py index 3aca3406..17a55c46 100644 --- a/sickbeard/metadata/ps3.py +++ b/sickbeard/metadata/ps3.py @@ -82,6 +82,9 @@ class PS3Metadata(generic.GenericMetadata): def create_show_metadata(self, show_obj, force=False): pass + def update_show_indexer_metadata(self, show_obj): + pass + def get_show_file_path(self, show_obj): pass diff --git a/sickbeard/metadata/tivo.py b/sickbeard/metadata/tivo.py index 06b88a0d..ec5c6a3b 100644 --- a/sickbeard/metadata/tivo.py +++ b/sickbeard/metadata/tivo.py @@ -90,6 +90,9 @@ class TIVOMetadata(generic.GenericMetadata): def create_show_metadata(self, show_obj, force=False): pass + def update_show_indexer_metadata(self, show_obj): + pass + def get_show_file_path(self, show_obj): pass diff --git a/sickbeard/metadata/wdtv.py b/sickbeard/metadata/wdtv.py index 00ad1a7f..b856e334 100644 --- a/sickbeard/metadata/wdtv.py +++ b/sickbeard/metadata/wdtv.py @@ -95,6 +95,9 @@ class WDTVMetadata(generic.GenericMetadata): def create_show_metadata(self, show_obj, force=False): pass + def update_show_indexer_metadata(self, show_obj): + pass + def get_show_file_path(self, show_obj): pass diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index aacad9f5..08c64a70 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -373,7 +373,8 @@ class ParseResult(object): return to_return.encode('utf-8') def convert(self): - if self.air_by_date: return self # scene numbering does not apply to air-by-date + if not self.series_name: return self # can't work without a series name + if self.air_by_date or self.sports: return self # scene numbering does not apply to air-by-date if self.season_number == None: return self # can't work without a season if len(self.episode_numbers) == 0: return self # need at least one episode diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index d226d657..e1befe05 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -210,21 +210,13 @@ class BTNProvider(generic.TorrentProvider): # Search for entire seasons: no need to do special things for air by date shows whole_season_params['category'] = 'Season' - whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) - - search_params.append(whole_season_params) - - # Search for episodes in the season - partial_season_params['category'] = 'Episode' - if ep_obj.show.air_by_date or ep_obj.show.sports: # Search for the year of the air by date show - partial_season_params['name'] = str(ep_obj.airdate).split('-')[0] + whole_season_params['name'] = str(ep_obj.airdate)[:7] else: - # Search for any result which has Sxx in the name - partial_season_params['name'] = 'S%02d' % int(ep_obj.scene_season) + whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) - search_params.append(partial_season_params) + search_params.append(whole_season_params) return search_params diff --git a/sickbeard/providers/dtt.py b/sickbeard/providers/dtt.py index 9fe91e55..b416ebb6 100644 --- a/sickbeard/providers/dtt.py +++ b/sickbeard/providers/dtt.py @@ -47,7 +47,7 @@ class DTTProvider(generic.TorrentProvider): return quality def getSearchResults(self, show, season, episodes, seasonSearch=False, manualSearch=False): - return generic.TorrentProvider.getSearchResults(self, show, season, episodes, seasonSearch, manualSearch) + return generic.TorrentProvider.findSearchResults(self, show, season, episodes, seasonSearch, manualSearch) def _dtt_show_id(self, show_name): return sanitizeSceneName(show_name).replace('.', '-').lower() diff --git a/sickbeard/providers/ezrss.py b/sickbeard/providers/ezrss.py index ccfcacb8..280e2abf 100644 --- a/sickbeard/providers/ezrss.py +++ b/sickbeard/providers/ezrss.py @@ -68,7 +68,7 @@ class EZRSSProvider(generic.TorrentProvider): logger.WARNING) return results - results = generic.TorrentProvider.getSearchResults(self, show, season, episodes, seasonSearch, manualSearch) + results = generic.TorrentProvider.findSearchResults(self, show, season, episodes, seasonSearch, manualSearch) return results @@ -78,12 +78,10 @@ class EZRSSProvider(generic.TorrentProvider): params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8') - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - params['season'] = ep_obj.scene_season + if ep_obj.show.air_by_date or ep_obj.show.sports: + params['season'] = str(ep_obj.airdate)[:7] else: - params['season'] = self._get_episode_search_strings(ep_obj)[0]['season'] - - #params['episode'] = self._get_episode_search_strings(ep_obj)[0]['episode'] + params['season'] = ep_obj.scene_season return [params] diff --git a/sickbeard/providers/hdbits.py b/sickbeard/providers/hdbits.py index e20f5317..7b51da8c 100644 --- a/sickbeard/providers/hdbits.py +++ b/sickbeard/providers/hdbits.py @@ -153,12 +153,18 @@ class HDBitsProvider(generic.TorrentProvider): 'episode': episode.scene_episode } - if season: - post_data['tvdb'] = { - 'id': show.indexerid, - 'season': season, - } - + if season: + if show.air_by_date or show.sports: + post_data['tvdb'] = { + 'id': show.indexerid, + 'season': str(episode.airdate)[:7], + } + else: + post_data['tvdb'] = { + 'id': show.indexerid, + 'season': season, + } + if search_term: post_data['search'] = search_term diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index 875604de..48a1cb6c 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -114,15 +114,14 @@ class HDTorrentsProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] + search_string['Season'].append(ep_string) - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 5721f466..253f0334 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -94,15 +94,13 @@ class IPTorrentsProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 65346f49..10a13b85 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -170,17 +170,18 @@ class KATProvider(generic.TorrentProvider): if not (ep_obj.show.air_by_date or ep_obj.show.sports): for show_name in set(allPossibleShowNames(self.show)): - ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int(ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + ' category:tv' #2) showName Season X + else: + ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int(ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE search_string['Season'].append(ep_string) - ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' + ' category:tv' #2) showName Season X + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + ' Season ' + str(ep_obj.airdate)[:7] + ' category:tv' #2) showName Season X + else: + ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' + ' category:tv' #2) showName Season X search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] - return [search_string] def _get_episode_search_strings(self, ep_obj, add_string=''): diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index f6e58333..c04c0709 100644 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -94,19 +94,13 @@ class NewznabProvider(generic.NZBProvider): cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # season - if not (ep_obj.show.air_by_date or ep_obj.show.sports): + if ep_obj.show.air_by_date or ep_obj.show.sports: + cur_params['season'] = str(ep_obj.airdate)[:7] + else: cur_params['season'] = str(ep_obj.scene_season) to_return.append(cur_params) - cur_params = {} - if ep_obj.show.air_by_date or ep_obj.show.sports: - cur_params['season'] = self._get_episode_search_strings(ep_obj)[0]['season'] - - #cur_params['episode'] = self._get_episode_search_strings(ep_obj)[0]['ep'] - - to_return.append(cur_params) - return to_return def _get_episode_search_strings(self, ep_obj, add_string=''): diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index 80a3cc7c..1f7230a0 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -134,15 +134,13 @@ class NextGenProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/nyaatorrents.py b/sickbeard/providers/nyaatorrents.py index 9828f151..3e0eccf0 100644 --- a/sickbeard/providers/nyaatorrents.py +++ b/sickbeard/providers/nyaatorrents.py @@ -50,18 +50,17 @@ class NyaaProvider(generic.TorrentProvider): return 'nyaatorrents.png' def getQuality(self, item, anime=False): - self.debug() title = item.title quality = Quality.sceneQuality(title) return quality def getSearchResults(self, show, season, episodes, seasonSearch=False, manualSearch=False): - results = generic.TorrentProvider.getSearchResults(self, show, season, episodes, seasonSearch, manualSearch) + results = generic.TorrentProvider.findSearchResults(self, show, season, episodes, seasonSearch, manualSearch) return results def _get_season_search_strings(self, ep_obj): names = [] - names.extend(show_name_helpers.makeSceneshowSearchStrings(self.show)) + names.extend(show_name_helpers.makeSceneShowSearchStrings(self.show)) return names def _get_episode_search_strings(self, ep_obj, add_string=''): diff --git a/sickbeard/providers/publichd.py b/sickbeard/providers/publichd.py index 98211685..1d4ab897 100644 --- a/sickbeard/providers/publichd.py +++ b/sickbeard/providers/publichd.py @@ -76,17 +76,18 @@ class PublicHDProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(allPossibleShowNames(self.show)): + for show_name in set(allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX -SXXE - search_string['Season'].append(ep_string) + search_string['Season'].append(ep_string) + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + ' Season ' + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' Season ' + str(ep_obj.scene_season) #2) showName Season X - search_string['Season'].append(ep_string) - else: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index 5f907489..542294bd 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -103,14 +103,13 @@ class SCCProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index 14a7eb4c..db3a790e 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -94,14 +94,13 @@ class SpeedCDProvider(generic.TorrentProvider): #If Every episode in Season is a wanted Episode then search for Season first search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name +' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 9bb0f6fb..98748bad 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -173,17 +173,19 @@ class ThePirateBayProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(allPossibleShowNames(self.show)) if not (ep_obj.show.air_by_date or ep_obj.show.sports) else []: + for show_name in set(allPossibleShowNames(self.show)) if not (ep_obj.show.air_by_date or ep_obj.show.sports) else []: + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) + search_string['Season'].append(ep_string) + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + ' Season ' + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' #2) showName Season X - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 35541458..f7ae83c1 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -121,14 +121,13 @@ class TorrentDayProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index 4ceaac39..f0af5ccf 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -98,14 +98,13 @@ class TorrentLeechProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + str(ep_obj.airdate)[:7] + else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - elif ep_obj.show.air_by_date or ep_obj.show.sports: - search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/show_name_helpers.py b/sickbeard/show_name_helpers.py index c7d2be51..18ea3337 100644 --- a/sickbeard/show_name_helpers.py +++ b/sickbeard/show_name_helpers.py @@ -119,7 +119,10 @@ def makeSceneSeasonSearchString(show, ep_obj, extraSearchType=None): [show.indexerid]) numseasons = int(numseasonsSQlResult[0][0]) - seasonStrings = ["S%02d" % int(ep_obj.scene_season)] + if show.air_by_date or show.sports: + seasonStrings = [str(ep_obj.airdate)[:7]] + else: + seasonStrings = ["S%02d" % int(ep_obj.scene_season)] showNames = set(makeSceneShowSearchStrings(show)) diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py index 437108ad..143b8f72 100644 --- a/sickbeard/show_queue.py +++ b/sickbeard/show_queue.py @@ -378,7 +378,8 @@ class QueueItemAdd(ShowQueueItem): logger.log(u"Launching backlog for this show since its episodes are WANTED") sickbeard.backlogSearchScheduler.action.searchBacklog([self.show]) #@UndefinedVariable - self.show.writeMetadata(force=True) + self.show.writeMetadata() + self.show.updateMetadata() self.show.populateCache() self.show.flushEpisodes() @@ -409,6 +410,7 @@ class QueueItemRefresh(ShowQueueItem): self.show.refreshDir() self.show.writeMetadata() + self.show.updateMetadata() self.show.populateCache() self.inProgress = False diff --git a/sickbeard/tv.py b/sickbeard/tv.py index fc0c0665..d436672d 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -253,7 +253,7 @@ class TVShow(object): return False - def writeShowNFO(self, force=False): + def writeShowNFO(self): result = False @@ -263,11 +263,11 @@ class TVShow(object): logger.log(str(self.indexerid) + u": Writing NFOs for show") for cur_provider in sickbeard.metadata_provider_dict.values(): - result = cur_provider.create_show_metadata(self, force) or result + result = cur_provider.create_show_metadata(self) or result return result - def writeMetadata(self, show_only=False, force=False): + def writeMetadata(self, show_only=False): if not ek.ek(os.path.isdir, self._location): logger.log(str(self.indexerid) + u": Show dir doesn't exist, skipping NFO generation") @@ -275,12 +275,12 @@ class TVShow(object): self.getImages() - self.writeShowNFO(force) + self.writeShowNFO() if not show_only: - self.writeEpisodeNFOs(force) + self.writeEpisodeNFOs() - def writeEpisodeNFOs(self, force=False): + def writeEpisodeNFOs(self): if not ek.ek(os.path.isdir, self._location): logger.log(str(self.indexerid) + u": Show dir doesn't exist, skipping NFO generation") @@ -295,9 +295,31 @@ class TVShow(object): logger.log(str(self.indexerid) + u": Retrieving/creating episode " + str(epResult["season"]) + "x" + str( epResult["episode"]), logger.DEBUG) curEp = self.getEpisode(epResult["season"], epResult["episode"]) - curEp.createMetaFiles(force) + curEp.createMetaFiles() + def updateMetadata(self): + + if not ek.ek(os.path.isdir, self._location): + logger.log(str(self.indexerid) + u": Show dir doesn't exist, skipping NFO generation") + return + + self.updateShowNFO() + + def updateShowNFO(self): + + result = False + + if not ek.ek(os.path.isdir, self._location): + logger.log(str(self.indexerid) + u": Show dir doesn't exist, skipping NFO generation") + return False + + logger.log(str(self.indexerid) + u": Updating NFOs for show with new indexer info") + for cur_provider in sickbeard.metadata_provider_dict.values(): + result = cur_provider.update_show_indexer_metadata(self) or result + + return result + # find all media files in the show folder and create episodes for as many as possible def loadEpisodesFromDir(self): @@ -1610,28 +1632,28 @@ class TVEpisode(object): toReturn += "status: " + str(self.status) + "\n" return toReturn - def createMetaFiles(self, force=False): + def createMetaFiles(self): if not ek.ek(os.path.isdir, self.show._location): logger.log(str(self.show.indexerid) + u": The show dir is missing, not bothering to try to create metadata") return - self.createNFO(force) + self.createNFO() self.createThumbnail() if self.checkForMetaFiles(): self.saveToDB() - def createNFO(self, force=False): + def createNFO(self): result = False for cur_provider in sickbeard.metadata_provider_dict.values(): - result = cur_provider.create_episode_metadata(self, force) or result + result = cur_provider.create_episode_metadata(self) or result return result - def createThumbnail(self, force=False): + def createThumbnail(self): result = False