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

Fixed metadata code to add proper indexer info to the tvshow.nfo files

This commit is contained in:
echel0n 2014-05-14 02:42:08 -07:00
parent 415e0df536
commit bde70f1881
6 changed files with 86 additions and 17 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

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