1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Merge branch 'origin/dev'

This commit is contained in:
echel0n 2014-05-14 02:42:28 -07:00
commit 5645eecd9c
24 changed files with 178 additions and 121 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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]

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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=''):

View File

@ -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=''):

View File

@ -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]

View File

@ -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=''):

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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))

View File

@ -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

View File

@ -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