本文整理汇总了Python中sickbeard.helpers.indentXML函数的典型用法代码示例。如果您正苦于以下问题:Python indentXML函数的具体用法?Python indentXML怎么用?Python indentXML使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了indentXML函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_show_indexer_metadata
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)
assert isinstance(nfo_file_path, unicode)
try:
with io.open(nfo_file_path, 'rb') as xmlFileObj:
showXML = etree.ElementTree(file=xmlFileObj)
indexerid = showXML.find('id')
root = showXML.getroot()
if indexerid is not None:
indexerid.text = str(show_obj.indexerid)
else:
etree.SubElement(root, "id").text = str(show_obj.indexerid)
# Make it purdy
helpers.indentXML(root)
showXML.write(nfo_file_path, encoding='UTF-8')
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)
示例2: update_show_indexer_metadata
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 %s updating show indexer metadata file for %s' % (self.name, show_obj.name),
logger.DEBUG)
nfo_file_path = self.get_show_file_path(show_obj)
with ek.ek(open, nfo_file_path, 'r') as xmlFileObj:
show_xml = etree.ElementTree(file=xmlFileObj)
indexer = show_xml.find('indexer')
indexerid = show_xml.find('id')
root = show_xml.getroot()
show_indexer = str(show_obj.indexer)
if None is not indexer:
indexer.text = show_indexer
else:
etree.SubElement(root, 'indexer').text = show_indexer
show_indexerid = str(show_obj.indexerid)
if None is not indexerid:
indexerid.text = show_indexerid
else:
etree.SubElement(root, 'id').text = show_indexerid
# Make it purdy
helpers.indentXML(root)
helpers.write_file(nfo_file_path, show_xml, xmltree=True, utf8=True)
return True
示例3: update_show_indexer_metadata
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)
indexerid = showXML.find("id")
root = showXML.getroot()
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,
)
示例4: _show_data
#.........这里部分代码省略.........
lINDEXER_API_PARMS['language'] = indexer_lang or sickbeard.INDEXER_DEFAULT_LANGUAGE
if show_obj.dvdorder:
lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
rootNode = etree.Element("details")
tv_node = etree.SubElement(rootNode, "movie")
tv_node.attrib["isExtra"] = "false"
tv_node.attrib["isSet"] = "false"
tv_node.attrib["isTV"] = "true"
try:
myShow = t[int(show_obj.indexerid)]
except sickbeard.indexer_shownotfound:
logger.log("Unable to find show with id " + str(show_obj.indexerid) + " on tvdb, skipping it", logger.ERROR)
raise
except sickbeard.indexer_error:
logger.log("TVDB is down, can't use its data to make the NFO", logger.ERROR)
raise
# check for title and id
if not (getattr(myShow, 'seriesname', None) and getattr(myShow, 'id', None)):
logger.log("Incomplete info for show with id " + str(show_obj.indexerid) + " on " + sickbeard.indexerApi(
show_obj.indexer).name + ", skipping it")
return False
SeriesName = etree.SubElement(tv_node, "title")
SeriesName.text = myShow['seriesname']
if getattr(myShow, "genre", None):
Genres = etree.SubElement(tv_node, "genres")
for genre in myShow['genre'].split('|'):
if genre and genre.strip():
cur_genre = etree.SubElement(Genres, "Genre")
cur_genre.text = genre.strip()
if getattr(myShow, 'firstaired', None):
FirstAired = etree.SubElement(tv_node, "premiered")
FirstAired.text = myShow['firstaired']
if getattr(myShow, "firstaired", None):
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], dateFormat).year)
if year_text:
year = etree.SubElement(tv_node, "year")
year.text = year_text
except Exception:
pass
if getattr(myShow, 'overview', None):
plot = etree.SubElement(tv_node, "plot")
plot.text = myShow["overview"]
if getattr(myShow, 'rating', None):
try:
rating = int(float(myShow['rating']) * 10)
except ValueError:
rating = 0
if rating:
Rating = etree.SubElement(tv_node, "rating")
Rating.text = str(rating)
if getattr(myShow, 'status', None):
Status = etree.SubElement(tv_node, "status")
Status.text = myShow['status']
if getattr(myShow, "contentrating", None):
mpaa = etree.SubElement(tv_node, "mpaa")
mpaa.text = myShow["contentrating"]
if getattr(myShow, 'imdb_id', None):
imdb_id = etree.SubElement(tv_node, "id")
imdb_id.attrib["moviedb"] = "imdb"
imdb_id.text = myShow['imdb_id']
if getattr(myShow, 'id', None):
indexerid = etree.SubElement(tv_node, "indexerid")
indexerid.text = myShow['id']
if getattr(myShow, 'runtime', None):
Runtime = etree.SubElement(tv_node, "runtime")
Runtime.text = myShow['runtime']
if getattr(myShow, '_actors', None):
cast = etree.SubElement(tv_node, "cast")
for actor in myShow['_actors']:
if 'name' in actor and actor['name'].strip():
cur_actor = etree.SubElement(cast, "actor")
cur_actor.text = actor['name'].strip()
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例5: _ep_data
#.........这里部分代码省略.........
except (sickbeard.indexer_episodenotfound, sickbeard.indexer_seasonnotfound):
logger.log("Metadata writer is unable to find episode {0:d}x{1:d} of {2} on {3}..."
"has it been removed? Should I delete from db?".format(
curEpToWrite.season, curEpToWrite.episode, curEpToWrite.show.name,
sickbeard.indexerApi(ep_obj.show.indexer).name))
return None
if curEpToWrite == ep_obj:
# root (or single) episode
# default to today's date for specials if firstaired is not set
if curEpToWrite.season == 0 and not getattr(myEp, 'firstaired', None):
myEp['firstaired'] = str(datetime.date.fromordinal(1))
if not (getattr(myEp, 'episodename', None) and getattr(myEp, 'firstaired', None)):
return None
episode = movie
if curEpToWrite.name:
EpisodeName = etree.SubElement(episode, "title")
EpisodeName.text = curEpToWrite.name
SeasonNumber = etree.SubElement(episode, "season")
SeasonNumber.text = str(curEpToWrite.season)
EpisodeNumber = etree.SubElement(episode, "episode")
EpisodeNumber.text = str(curEpToWrite.episode)
if getattr(myShow, "firstaired", None):
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], dateFormat).year)
if year_text:
year = etree.SubElement(episode, "year")
year.text = year_text
except Exception:
pass
if getattr(myShow, "overview", None):
plot = etree.SubElement(episode, "plot")
plot.text = myShow["overview"]
if curEpToWrite.description:
Overview = etree.SubElement(episode, "episodeplot")
Overview.text = curEpToWrite.description
if getattr(myShow, 'contentrating', None):
mpaa = etree.SubElement(episode, "mpaa")
mpaa.text = myShow["contentrating"]
if not ep_obj.relatedEps and getattr(myEp, "rating", None):
try:
rating = int((float(myEp['rating']) * 10))
except ValueError:
rating = 0
if rating:
Rating = etree.SubElement(episode, "rating")
Rating.text = str(rating)
if getattr(myEp, 'director', None):
director = etree.SubElement(episode, "director")
director.text = myEp['director']
if getattr(myEp, 'writer', None):
writer = etree.SubElement(episode, "credits")
writer.text = myEp['writer']
if getattr(myShow, '_actors', None) or getattr(myEp, 'gueststars', None):
cast = etree.SubElement(episode, "cast")
if getattr(myEp, 'gueststars', None) and isinstance(myEp['gueststars'], six.string_types):
for actor in (x.strip() for x in myEp['gueststars'].split('|') if x.strip()):
cur_actor = etree.SubElement(cast, "actor")
cur_actor.text = actor
if getattr(myShow, '_actors', None):
for actor in myShow['_actors']:
if 'name' in actor and actor['name'].strip():
cur_actor = etree.SubElement(cast, "actor")
cur_actor.text = actor['name'].strip()
else:
# append data from (if any) related episodes
if curEpToWrite.name:
if not EpisodeName.text:
EpisodeName.text = curEpToWrite.name
else:
EpisodeName.text = EpisodeName.text + ", " + curEpToWrite.name
if curEpToWrite.description:
if not Overview.text:
Overview.text = curEpToWrite.description
else:
Overview.text = Overview.text + "\r" + curEpToWrite.description
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例6: _show_data
#.........这里部分代码省略.........
# check for title and id
try:
if myShow["seriesname"] == None or myShow["seriesname"] == "" or myShow["id"] == None or myShow["id"] == "":
logger.log(
"Mede8er: Incomplete info for show with id " + str(show_obj.tvdbid) + " on tvdb, skipping it",
logger.ERROR,
)
return False
except tvdb_exceptions.tvdb_attributenotfound:
logger.log(
"Mede8er: Incomplete info for show with id " + str(show_obj.tvdbid) + " on tvdb, skipping it",
logger.ERROR,
)
return False
title = etree.SubElement(tv_node, "title")
if myShow["seriesname"] != None:
title.text = myShow["seriesname"]
tvdbid = etree.SubElement(tv_node, "tvdbid")
if myShow["id"] != None:
tvdbid.text = myShow["id"]
seriesID = etree.SubElement(tv_node, "seriesID")
if myShow["seriesid"] != None:
seriesID.text = myShow["seriesid"]
imdbid = etree.SubElement(tv_node, "imdbid")
if myShow["imdb_id"] != None:
imdbid.text = myShow["imdb_id"]
zap2id = etree.SubElement(tv_node, "zap2itid")
if myShow["zap2it_id"] != None:
zap2id.text = myShow["zap2it_id"]
premiered = etree.SubElement(tv_node, "releasedate")
if myShow["firstaired"] != None:
premiered.text = myShow["firstaired"]
rating = etree.SubElement(tv_node, "rating")
if myShow["rating"] != None:
rating.text = myShow["rating"]
ratingcount = etree.SubElement(tv_node, "ratingcount")
if myShow["ratingcount"] != None:
ratingcount.text = myShow["ratingcount"]
network = etree.SubElement(tv_node, "network")
if myShow["network"] != None:
network.text = myShow["network"]
Runtime = etree.SubElement(tv_node, "runtime")
if myShow["runtime"] != None:
Runtime.text = myShow["runtime"]
genre = etree.SubElement(tv_node, "genre")
if myShow["genre"] != None:
genre.text = myShow["genre"]
# tmpNode = etree.SubElement(tv_node, "myShow")
# tmpNode.text = str(vars(myShow))
# logger.log("Printing myShow info: " + str(vars(myShow)), logger.MESSAGE)
# Actors = etree.SubElement(tv_node, "Actors")
# if myShow["actors"] != None:
# Actors.text = myShow["actors"]
rating = etree.SubElement(tv_node, "certification")
if myShow["contentrating"] != None:
rating.text = myShow["contentrating"]
Overview = etree.SubElement(tv_node, "plot")
if myShow["overview"] != None:
Overview.text = myShow["overview"]
cast = etree.SubElement(tv_node, "cast")
for actor in myShow["_actors"]:
cast_actor = etree.SubElement(cast, "actor")
cast_actor.text = actor["name"]
rating = etree.SubElement(tv_node, "Status")
if myShow["status"] != None:
rating.text = myShow["status"]
cover = etree.SubElement(tv_node, "cover")
poster = etree.SubElement(cover, "name")
if myShow["poster"] != None:
poster.text = myShow["poster"]
backdrop = etree.SubElement(tv_node, "backdrop")
fanart = etree.SubElement(backdrop, "name")
if myShow["fanart"] != None:
fanart.text = myShow["fanart"]
helpers.indentXML(tv_node)
data = etree.ElementTree(tv_node)
return data
示例7: _show_data
#.........这里部分代码省略.........
tv_node = etree.Element('tvshow')
try:
myShow = t[int(show_ID)]
except sickbeard.indexer_shownotfound:
logger.log(u'Unable to find show with id ' + str(show_ID) + ' on ' + sickbeard.indexerApi(
show_obj.indexer).name + ', skipping it', logger.ERROR)
raise
except sickbeard.indexer_error:
logger.log(
u'' + sickbeard.indexerApi(show_obj.indexer).name + ' is down, can\'t use its data to add this show',
logger.ERROR)
raise
# check for title and id
if getattr(myShow, 'seriesname', None) is None or getattr(myShow, 'id', None) is None:
logger.log(u'Incomplete info for show with id ' + str(show_ID) + ' on ' + sickbeard.indexerApi(
show_obj.indexer).name + ', skipping it', logger.ERROR)
return False
title = etree.SubElement(tv_node, 'title')
if getattr(myShow, 'seriesname', None) is not None:
title.text = myShow['seriesname']
rating = etree.SubElement(tv_node, 'rating')
if getattr(myShow, 'rating', None) is not None:
rating.text = myShow['rating']
year = etree.SubElement(tv_node, 'year')
if getattr(myShow, 'firstaired', None) is not None:
try:
year_text = str(datetime.datetime.strptime(myShow['firstaired'], '%Y-%m-%d').year)
if year_text:
year.text = year_text
except:
pass
plot = etree.SubElement(tv_node, 'plot')
if getattr(myShow, 'overview', None) is not None:
plot.text = myShow['overview']
episodeguide = etree.SubElement(tv_node, 'episodeguide')
episodeguideurl = etree.SubElement(episodeguide, 'url')
episodeguideurl2 = etree.SubElement(tv_node, 'episodeguideurl')
if getattr(myShow, 'id', None) is not None:
showurl = sickbeard.indexerApi(show_obj.indexer).config['base_url'] + str(myShow['id']) + '/all/en.zip'
episodeguideurl.text = showurl
episodeguideurl2.text = showurl
mpaa = etree.SubElement(tv_node, 'mpaa')
if getattr(myShow, 'contentrating', None) is not None:
mpaa.text = myShow['contentrating']
indexerid = etree.SubElement(tv_node, 'id')
if getattr(myShow, 'id', None) is not None:
indexerid.text = str(myShow['id'])
indexer = etree.SubElement(tv_node, 'indexer')
if show_obj.indexer is not None:
indexer.text = str(show_obj.indexer)
genre = etree.SubElement(tv_node, 'genre')
if getattr(myShow, 'genre', None) is not None:
if isinstance(myShow['genre'], basestring):
genre.text = ' / '.join(x.strip() for x in myShow['genre'].split('|') if x.strip())
premiered = etree.SubElement(tv_node, 'premiered')
if getattr(myShow, 'firstaired', None) is not None:
premiered.text = myShow['firstaired']
studio = etree.SubElement(tv_node, 'studio')
if getattr(myShow, 'network', None) is not None:
studio.text = myShow['network']
if getattr(myShow, '_actors', None) is not None:
for actor in myShow['_actors']:
cur_actor = etree.SubElement(tv_node, 'actor')
cur_actor_name = etree.SubElement(cur_actor, 'name')
cur_actor_name_text = actor['name']
if isinstance(cur_actor_name_text, basestring):
cur_actor_name.text = cur_actor_name_text.strip()
cur_actor_role = etree.SubElement(cur_actor, 'role')
cur_actor_role_text = actor['role']
if cur_actor_role_text != None:
cur_actor_role.text = cur_actor_role_text
cur_actor_thumb = etree.SubElement(cur_actor, 'thumb')
cur_actor_thumb_text = actor['image']
if cur_actor_thumb_text != None:
cur_actor_thumb.text = cur_actor_thumb_text
# Make it purdy
helpers.indentXML(tv_node)
data = etree.ElementTree(tv_node)
return data
示例8: _ep_data
#.........这里部分代码省略.........
FirstAired = etree.SubElement(episode, "FirstAired")
FirstAired.text = str(curEpToWrite.airdate)
MetadataType = etree.SubElement(episode, "Type")
MetadataType.text = "Episode"
if curEpToWrite.description:
Overview = etree.SubElement(episode, "Overview")
Overview.text = curEpToWrite.description
if not ep_obj.relatedEps:
if getattr(myEp, 'rating', None):
Rating = etree.SubElement(episode, "Rating")
Rating.text = myEp['rating']
if getattr(myShow, 'imdb_id', None):
IMDB_ID = etree.SubElement(episode, "IMDB_ID")
IMDB_ID.text = myShow['imdb_id']
IMDB = etree.SubElement(episode, "IMDB")
IMDB.text = myShow['imdb_id']
IMDbId = etree.SubElement(episode, "IMDbId")
IMDbId.text = myShow['imdb_id']
indexerid = etree.SubElement(episode, "id")
indexerid.text = str(curEpToWrite.indexerid)
Persons = etree.SubElement(episode, "Persons")
if getattr(myShow, '_actors', None):
for actor in myShow['_actors']:
if not ('name' in actor and actor['name'].strip()):
continue
cur_actor = etree.SubElement(Persons, "Person")
cur_actor_name = etree.SubElement(cur_actor, "Name")
cur_actor_name.text = actor['name'].strip()
cur_actor_type = etree.SubElement(cur_actor, "Type")
cur_actor_type.text = "Actor"
if 'role' in actor and actor['role'].strip():
cur_actor_role = etree.SubElement(cur_actor, "Role")
cur_actor_role.text = actor['role'].strip()
Language = etree.SubElement(episode, "Language")
try:
Language.text = myEp['language']
except Exception:
Language.text = sickbeard.INDEXER_DEFAULT_LANGUAGE # tvrage api doesn't provide language so we must assume a value here
thumb = etree.SubElement(episode, "filename")
# TODO: See what this is needed for.. if its still needed
# just write this to the NFO regardless of whether it actually exists or not
# note: renaming files after nfo generation will break this, tough luck
thumb_text = self.get_episode_thumb_path(ep_obj)
if thumb_text:
thumb.text = thumb_text
else:
# append data from (if any) related episodes
EpisodeNumberEnd.text = str(curEpToWrite.episode)
if curEpToWrite.name:
if not EpisodeName.text:
EpisodeName.text = curEpToWrite.name
else:
EpisodeName.text = EpisodeName.text + ", " + curEpToWrite.name
if curEpToWrite.description:
if not Overview.text:
Overview.text = curEpToWrite.description
else:
Overview.text = Overview.text + "\r" + curEpToWrite.description
# collect all directors, guest stars and writers
if getattr(myEp, 'director', None):
persons_dict['Director'] += [x.strip() for x in myEp['director'].split('|') if x.strip()]
if getattr(myEp, 'gueststars', None):
persons_dict['GuestStar'] += [x.strip() for x in myEp['gueststars'].split('|') if x.strip()]
if getattr(myEp, 'writer', None):
persons_dict['Writer'] += [x.strip() for x in myEp['writer'].split('|') if x.strip()]
# fill in Persons section with collected directors, guest starts and writers
for person_type, names in six.iteritems(persons_dict):
# remove doubles
names = list(set(names))
for cur_name in names:
Person = etree.SubElement(Persons, "Person")
cur_person_name = etree.SubElement(Person, "Name")
cur_person_name.text = cur_name
cur_person_type = etree.SubElement(Person, "Type")
cur_person_type.text = person_type
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例9: _show_data
#.........这里部分代码省略.........
tvdb_lang = show_obj.lang
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy()
if tvdb_lang and not tvdb_lang == 'en':
ltvdb_api_parms['language'] = tvdb_lang
t = tvdb_api.Tvdb(actors=True, **ltvdb_api_parms)
tv_node = etree.Element("tvshow")
for ns in XML_NSMAP.keys():
tv_node.set(ns, XML_NSMAP[ns])
try:
myShow = t[int(show_ID)]
except tvdb_exceptions.tvdb_shownotfound:
logger.log(u"Unable to find show with id " + str(show_ID) + " on tvdb, skipping it", logger.ERROR)
raise
except tvdb_exceptions.tvdb_error:
logger.log(u"TVDB is down, can't use its data to add this show", logger.ERROR)
raise
# check for title and id
try:
if myShow["seriesname"] == None or myShow["seriesname"] == "" or myShow["id"] == None or myShow["id"] == "":
logger.log(u"Incomplete info for show with id " + str(show_ID) + " on tvdb, skipping it", logger.ERROR)
return False
except tvdb_exceptions.tvdb_attributenotfound:
logger.log(u"Incomplete info for show with id " + str(show_ID) + " on tvdb, skipping it", logger.ERROR)
return False
title = etree.SubElement(tv_node, "title")
if myShow["seriesname"] != None:
title.text = myShow["seriesname"]
rating = etree.SubElement(tv_node, "rating")
if myShow["rating"] != None:
rating.text = myShow["rating"]
plot = etree.SubElement(tv_node, "plot")
if myShow["overview"] != None:
plot.text = myShow["overview"]
episodeguide = etree.SubElement(tv_node, "episodeguide")
episodeguideurl = etree.SubElement( episodeguide, "url")
episodeguideurl2 = etree.SubElement(tv_node, "episodeguideurl")
if myShow["id"] != None:
showurl = sickbeard.TVDB_BASE_URL + '/series/' + myShow["id"] + '/all/en.zip'
episodeguideurl.text = showurl
episodeguideurl2.text = showurl
mpaa = etree.SubElement(tv_node, "mpaa")
if myShow["contentrating"] != None:
mpaa.text = myShow["contentrating"]
tvdbid = etree.SubElement(tv_node, "id")
if myShow["id"] != None:
tvdbid.text = myShow["id"]
genre = etree.SubElement(tv_node, "genre")
if myShow["genre"] != None:
genre.text = " / ".join([x for x in myShow["genre"].split('|') if x])
premiered = etree.SubElement(tv_node, "premiered")
if myShow["firstaired"] != None:
premiered.text = myShow["firstaired"]
studio = etree.SubElement(tv_node, "studio")
if myShow["network"] != None:
studio.text = myShow["network"]
for actor in myShow['_actors']:
cur_actor = etree.SubElement(tv_node, "actor")
cur_actor_name = etree.SubElement( cur_actor, "name")
cur_actor_name.text = actor['name']
cur_actor_role = etree.SubElement( cur_actor, "role")
cur_actor_role_text = actor['role']
if cur_actor_role_text != None:
cur_actor_role.text = cur_actor_role_text
cur_actor_thumb = etree.SubElement( cur_actor, "thumb")
cur_actor_thumb_text = actor['image']
if cur_actor_thumb_text != None:
cur_actor_thumb.text = cur_actor_thumb_text
# Make it purdy
helpers.indentXML(tv_node)
data = etree.ElementTree(tv_node)
return data
示例10: _ep_data
#.........这里部分代码省略.........
if not getattr(myEp, 'episodename', None):
logger.log(u"Not generating nfo because the ep has no title", logger.DEBUG)
return None
logger.log(u"Creating metadata for episode " + str(ep_obj.season) + "x" + str(ep_obj.episode), logger.DEBUG)
if len(eps_to_write) > 1:
episode = etree.SubElement(rootNode, "episodedetails")
else:
episode = rootNode
if getattr(myEp, 'episodename', None):
title = etree.SubElement(episode, "title")
title.text = myEp['episodename']
if getattr(myShow, 'seriesname', None):
showtitle = etree.SubElement(episode, "showtitle")
showtitle.text = myShow['seriesname']
season = etree.SubElement(episode, "season")
season.text = str(curEpToWrite.season)
episodenum = etree.SubElement(episode, "episode")
episodenum.text = str(curEpToWrite.episode)
uniqueid = etree.SubElement(episode, "uniqueid")
uniqueid.text = str(curEpToWrite.indexerid)
if curEpToWrite.airdate != datetime.date.fromordinal(1):
aired = etree.SubElement(episode, "aired")
aired.text = str(curEpToWrite.airdate)
if getattr(myEp, 'overview', None):
plot = etree.SubElement(episode, "plot")
plot.text = myEp['overview']
if curEpToWrite.season and getattr(myShow, 'runtime', None):
runtime = etree.SubElement(episode, "runtime")
runtime.text = myShow["runtime"]
if getattr(myEp, 'airsbefore_season', None):
displayseason = etree.SubElement(episode, "displayseason")
displayseason.text = myEp['airsbefore_season']
if getattr(myEp, 'airsbefore_episode', None):
displayepisode = etree.SubElement(episode, "displayepisode")
displayepisode.text = myEp['airsbefore_episode']
if getattr(myEp, 'filename', None):
thumb = etree.SubElement(episode, "thumb")
thumb.text = myEp['filename'].strip()
# watched = etree.SubElement(episode, "watched")
# watched.text = 'false'
if getattr(myEp, 'rating', None):
rating = etree.SubElement(episode, "rating")
rating.text = myEp['rating']
if getattr(myEp, 'writer', None) and isinstance(myEp['writer'], basestring):
for writer in self._split_info(myEp['writer']):
cur_writer = etree.SubElement(episode, "credits")
cur_writer.text = writer
if getattr(myEp, 'director', None) and isinstance(myEp['director'], basestring):
for director in self._split_info(myEp['director']):
cur_director = etree.SubElement(episode, "director")
cur_director.text = director
if getattr(myEp, 'gueststars', None) and isinstance(myEp['gueststars'], basestring):
for actor in self._split_info(myEp['gueststars']):
cur_actor = etree.SubElement(episode, "actor")
cur_actor_name = etree.SubElement(cur_actor, "name")
cur_actor_name.text = actor
if getattr(myShow, '_actors', None):
for actor in myShow['_actors']:
cur_actor = etree.SubElement(episode, "actor")
if 'name' in actor and actor['name'].strip():
cur_actor_name = etree.SubElement(cur_actor, "name")
cur_actor_name.text = actor['name'].strip()
else:
continue
if 'role' in actor and actor['role'].strip():
cur_actor_role = etree.SubElement(cur_actor, "role")
cur_actor_role.text = actor['role'].strip()
if 'image' in actor and actor['image'].strip():
cur_actor_thumb = etree.SubElement(cur_actor, "thumb")
cur_actor_thumb.text = actor['image'].strip()
# Make it purdy
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例11: _show_data
#.........这里部分代码省略.........
lINDEXER_API_PARMS['actors'] = True
if indexer_lang and not indexer_lang == sickbeard.INDEXER_DEFAULT_LANGUAGE:
lINDEXER_API_PARMS['language'] = indexer_lang
if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
tv_node = etree.Element("tvshow")
try:
myShow = t[int(show_ID)]
except sickbeard.indexer_shownotfound:
logger.log(u"Unable to find show with id " + str(show_ID) + " on " + sickbeard.indexerApi(
show_obj.indexer).name + ", skipping it", logger.ERROR)
raise
except sickbeard.indexer_error:
logger.log(
u"" + sickbeard.indexerApi(show_obj.indexer).name + " is down, can't use its data to add this show",
logger.ERROR)
raise
# check for title and id
if getattr(myShow, 'seriesname', None) is None or getattr(myShow, 'id', None) is None:
logger.log(u"Incomplete info for show with id " + str(show_ID) + " on " + sickbeard.indexerApi(
show_obj.indexer).name + ", skipping it", logger.ERROR)
return False
title = etree.SubElement(tv_node, "title")
if getattr(myShow, 'seriesname', None) is not None:
title.text = myShow["seriesname"]
rating = etree.SubElement(tv_node, "rating")
if getattr(myShow, 'rating', None) is not None:
rating.text = myShow["rating"]
year = etree.SubElement(tv_node, "year")
if getattr(myShow, 'firstaired', None) is not None:
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], dateFormat).year)
if year_text:
year.text = year_text
except:
pass
plot = etree.SubElement(tv_node, "plot")
if getattr(myShow, 'overview', None) is not None:
plot.text = myShow["overview"]
episodeguide = etree.SubElement(tv_node, "episodeguide")
episodeguideurl = etree.SubElement(episodeguide, "url")
if getattr(myShow, 'id', None) is not None:
episodeguideurl.text = sickbeard.indexerApi(show_obj.indexer).config['base_url'] + str(myShow["id"]) + '/all/en.zip'
mpaa = etree.SubElement(tv_node, "mpaa")
if getattr(myShow, 'contentrating', None) is not None:
mpaa.text = myShow["contentrating"]
indexerid = etree.SubElement(tv_node, "id")
if getattr(myShow, 'id', None) is not None:
indexerid.text = str(myShow["id"])
genre = etree.SubElement(tv_node, "genre")
if getattr(myShow, 'genre', None) is not None:
if isinstance(myShow["genre"], basestring):
genre.text = " / ".join(x.strip() for x in myShow["genre"].split('|') if x.strip())
premiered = etree.SubElement(tv_node, "premiered")
if getattr(myShow, 'firstaired', None) is not None:
premiered.text = myShow["firstaired"]
studio = etree.SubElement(tv_node, "studio")
if getattr(myShow, 'network', None) is not None:
studio.text = myShow["network"]
if getattr(myShow, '_actors', None) is not None:
for actor in myShow['_actors']:
cur_actor = etree.SubElement(tv_node, "actor")
cur_actor_name = etree.SubElement(cur_actor, "name")
if getattr(actor, 'name', None) is not None:
cur_actor_name.text = actor['name'].strip()
cur_actor_role = etree.SubElement(cur_actor, "role")
if getattr(actor, 'role', None) is not None:
cur_actor_role.text = actor['role']
cur_actor_thumb = etree.SubElement(cur_actor, "thumb")
if getattr(actor, 'image', None) is not None:
cur_actor_thumb.text = actor['image']
# Make it purdy
helpers.indentXML(tv_node)
data = etree.ElementTree(tv_node)
return data
示例12: _show_data
#.........这里部分代码省略.........
lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
rootNode = etree.Element("details")
tv_node = etree.SubElement(rootNode, "movie")
tv_node.attrib["isExtra"] = "false"
tv_node.attrib["isSet"] = "false"
tv_node.attrib["isTV"] = "true"
try:
myShow = t[int(show_obj.indexerid)]
except sickbeard.indexer_shownotfound:
logger.log(u"Unable to find show with id " + str(show_obj.indexerid) + " on tvdb, skipping it", logger.ERROR)
raise
except sickbeard.indexer_error:
logger.log(u"TVDB is down, can't use its data to make the NFO", logger.ERROR)
raise
# check for title and id
try:
if getattr(myShow, 'seriesname', None) == None or getattr(myShow, 'seriesname', "") == "" or getattr(myShow, 'id', None) == None or getattr(myShow, 'id', "") == "":
logger.log(u"Incomplete info for show with id " + str(show_obj.indexerid) + " on tvdb, skipping it", logger.ERROR)
return False
except sickbeard.indexer_attributenotfound:
logger.log(u"Incomplete info for show with id " + str(show_obj.indexerid) + " on tvdb, skipping it", logger.ERROR)
return False
SeriesName = etree.SubElement(tv_node, "title")
SeriesName.text = myShow['seriesname']
Genres = etree.SubElement(tv_node, "genres")
if getattr(myShow, "genre", None) != None:
for genre in myShow['genre'].split('|'):
if genre and genre.strip():
cur_genre = etree.SubElement(Genres, "Genre")
cur_genre.text = genre.strip()
FirstAired = etree.SubElement(tv_node, "premiered")
if getattr(myShow, 'firstaired', None) != None:
FirstAired.text = myShow['firstaired']
year = etree.SubElement(tv_node, "year")
if getattr(myShow, "firstaired", None) != None:
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], '%Y-%m-%d').year)
if year_text:
year.text = year_text
except:
pass
plot = etree.SubElement(tv_node, "plot")
if getattr(myShow, 'overview', None) is not None:
plot.text = myShow["overview"]
if getattr(myShow, 'rating', None) != None:
try:
rating = int((float(myShow['rating']) * 10))
except ValueError:
rating = 0
Rating = etree.SubElement(tv_node, "rating")
rating_text = str(rating)
if rating_text != None:
Rating.text = rating_text
Status = etree.SubElement(tv_node, "status")
if getattr(myShow, 'status', None) != None:
Status.text = myShow['status']
mpaa = etree.SubElement(tv_node, "mpaa")
if getattr(myShow, "contentrating", None) != None:
mpaa.text = myShow["contentrating"]
IMDB_ID = etree.SubElement(tv_node, "id")
if getattr(myShow, 'imdb_id', None) != None:
IMDB_ID.attrib["moviedb"] = "imdb"
IMDB_ID.text = myShow['imdb_id']
indexerid = etree.SubElement(tv_node, "indexerid")
if getattr(myShow, 'id', None) != None:
indexerid.text = myShow['id']
Runtime = etree.SubElement(tv_node, "runtime")
if getattr(myShow, 'runtime', None) != None:
Runtime.text = myShow['runtime']
cast = etree.SubElement(tv_node, "cast")
if getattr(myShow, '_actors', None) is not None:
for actor in myShow['_actors']:
cur_actor_name_text = getattr(actor, 'name', None)
if cur_actor_name_text != None and cur_actor_name_text.strip():
cur_actor = etree.SubElement(cast, "actor")
cur_actor.text = cur_actor_name_text.strip()
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例13: _show_data
#.........这里部分代码省略.........
t = tvdb_api.Tvdb(actors=True, **ltvdb_api_parms)
rootNode = etree.Element("details")
tv_node = etree.SubElement(rootNode, "movie")
tv_node.attrib["isExtra"] = "false"
tv_node.attrib["isSet"] = "false"
tv_node.attrib["isTV"] = "true"
try:
myShow = t[int(show_obj.tvdbid)]
except tvdb_exceptions.tvdb_shownotfound:
logger.log(u"Unable to find show with id " + str(show_obj.tvdbid) + " on tvdb, skipping it", logger.ERROR)
raise
except tvdb_exceptions.tvdb_error:
logger.log(u"TVDB is down, can't use its data to make the NFO", logger.ERROR)
raise
# check for title and id
try:
if myShow['seriesname'] == None or myShow['seriesname'] == "" or myShow['id'] == None or myShow['id'] == "":
logger.log(u"Incomplete info for show with id " + str(show_obj.tvdbid) + " on tvdb, skipping it", logger.ERROR)
return False
except tvdb_exceptions.tvdb_attributenotfound:
logger.log(u"Incomplete info for show with id " + str(show_obj.tvdbid) + " on tvdb, skipping it", logger.ERROR)
return False
SeriesName = etree.SubElement(tv_node, "title")
if myShow['seriesname'] != None:
SeriesName.text = myShow['seriesname']
else:
SeriesName.text = ""
Genres = etree.SubElement(tv_node, "genres")
if myShow["genre"] != None:
for genre in myShow['genre'].split('|'):
if genre and genre.strip():
cur_genre = etree.SubElement(Genres, "Genre")
cur_genre.text = genre.strip()
FirstAired = etree.SubElement(tv_node, "premiered")
if myShow['firstaired'] != None:
FirstAired.text = myShow['firstaired']
year = etree.SubElement(tv_node, "year")
if myShow["firstaired"] != None:
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], '%Y-%m-%d').year)
if year_text:
year.text = year_text
except:
pass
if myShow['rating'] != None:
try:
rating = int((float(myShow['rating']) * 10))
except ValueError:
rating = 0
Rating = etree.SubElement(tv_node, "rating")
rating_text = str(rating)
if rating_text != None:
Rating.text = rating_text
Status = etree.SubElement(tv_node, "status")
if myShow['status'] != None:
Status.text = myShow['status']
mpaa = etree.SubElement(tv_node, "mpaa")
if myShow["contentrating"] != None:
mpaa.text = myShow["contentrating"]
IMDB_ID = etree.SubElement(tv_node, "id")
if myShow['imdb_id'] != None:
IMDB_ID.attrib["moviedb"] = "imdb"
IMDB_ID.text = myShow['imdb_id']
tvdbid = etree.SubElement(tv_node, "tvdbid")
if myShow['id'] != None:
tvdbid.text = myShow['id']
Runtime = etree.SubElement(tv_node, "runtime")
if myShow['runtime'] != None:
Runtime.text = myShow['runtime']
cast = etree.SubElement(tv_node, "cast")
if myShow["_actors"] != None:
for actor in myShow['_actors']:
cur_actor_name_text = actor['name']
if cur_actor_name_text != None and cur_actor_name_text.strip():
cur_actor = etree.SubElement(cast, "actor")
cur_actor.text = cur_actor_name_text.strip()
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例14: _ep_data
#.........这里部分代码省略.........
logger.log(u"Unable to connect to " + sickbeard.indexerApi(
ep_obj.show.indexer).name + " while creating meta files - skipping - " + ex(e), logger.ERROR)
return False
if not self._valid_show(myShow, ep_obj.show):
return
rootNode = etree.Element("details")
# write an WDTV XML containing info for all matching episodes
for curEpToWrite in eps_to_write:
try:
myEp = myShow[curEpToWrite.season][curEpToWrite.episode]
except (StandardError, Exception):
logger.log(u"Unable to find episode " + str(curEpToWrite.season) + "x" + str(
curEpToWrite.episode) + " on " + sickbeard.indexerApi(
ep_obj.show.indexer).name + "... has it been removed? Should I delete from db?")
return None
if getattr(myEp, 'firstaired', None) is None and ep_obj.season == 0:
myEp["firstaired"] = str(datetime.date.fromordinal(1))
if getattr(myEp, 'episodename', None) is None or getattr(myEp, 'firstaired', None) is None:
return None
if len(eps_to_write) > 1:
episode = etree.SubElement(rootNode, "details")
else:
episode = rootNode
# TODO: get right EpisodeID
episodeID = etree.SubElement(episode, "id")
episodeID.text = str(curEpToWrite.indexerid)
title = etree.SubElement(episode, "title")
title.text = ep_obj.prettyName()
seriesName = etree.SubElement(episode, "series_name")
if getattr(myShow, 'seriesname', None) is not None:
seriesName.text = myShow["seriesname"]
episodeName = etree.SubElement(episode, "episode_name")
if curEpToWrite.name != None:
episodeName.text = curEpToWrite.name
seasonNumber = etree.SubElement(episode, "season_number")
seasonNumber.text = str(curEpToWrite.season)
episodeNum = etree.SubElement(episode, "episode_number")
episodeNum.text = str(curEpToWrite.episode)
firstAired = etree.SubElement(episode, "firstaired")
if curEpToWrite.airdate != datetime.date.fromordinal(1):
firstAired.text = str(curEpToWrite.airdate)
year = etree.SubElement(episode, "year")
if getattr(myShow, 'firstaired', None) is not None:
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], '%Y-%m-%d').year)
if year_text:
year.text = year_text
except:
pass
runtime = etree.SubElement(episode, "runtime")
if curEpToWrite.season != 0:
if getattr(myShow, 'runtime', None) is not None:
runtime.text = myShow["runtime"]
genre = etree.SubElement(episode, "genre")
if getattr(myShow, 'genre', None) is not None:
genre.text = " / ".join([x for x in myShow["genre"].split('|') if x])
director = etree.SubElement(episode, "director")
director_text = getattr(myEp, 'director', None)
if director_text is not None:
director.text = director_text
for actor in getattr(myShow, 'actors', []):
cur_actor = etree.SubElement(episode, 'actor')
cur_actor_name = etree.SubElement(cur_actor, 'name')
cur_actor_name.text = actor['person']['name']
cur_actor_role = etree.SubElement(cur_actor, 'role')
cur_actor_role_text = actor['character']['name']
if cur_actor_role_text:
cur_actor_role.text = cur_actor_role_text
overview = etree.SubElement(episode, "overview")
if curEpToWrite.description != None:
overview.text = curEpToWrite.description
# Make it purdy
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data
示例15: _ep_data
#.........这里部分代码省略.........
)
return None
if curEpToWrite == ep_obj:
# root (or single) episode
# default to today's date for specials if firstaired is not set
if myEp["firstaired"] == None and ep_obj.season == 0:
myEp["firstaired"] = str(datetime.date.fromordinal(1))
if myEp["episodename"] == None or myEp["firstaired"] == None:
return None
episode = movie
EpisodeName = etree.SubElement(episode, "title")
if curEpToWrite.name != None:
EpisodeName.text = curEpToWrite.name
else:
EpisodeName.text = ""
SeasonNumber = etree.SubElement(episode, "season")
SeasonNumber.text = str(curEpToWrite.season)
EpisodeNumber = etree.SubElement(episode, "episode")
EpisodeNumber.text = str(ep_obj.episode)
year = etree.SubElement(episode, "year")
if myShow["firstaired"] != None:
try:
year_text = str(datetime.datetime.strptime(myShow["firstaired"], "%Y-%m-%d").year)
if year_text:
year.text = year_text
except:
pass
plot = etree.SubElement(episode, "plot")
if myShow["overview"] != None:
plot.text = myShow["overview"]
Overview = etree.SubElement(episode, "episodeplot")
if curEpToWrite.description != None:
Overview.text = curEpToWrite.description
else:
Overview.text = ""
mpaa = etree.SubElement(episode, "mpaa")
if myShow["contentrating"] != None:
mpaa.text = myShow["contentrating"]
if not ep_obj.relatedEps:
if myEp["rating"] != None:
try:
rating = int((float(myEp["rating"]) * 10))
except ValueError:
rating = 0
Rating = etree.SubElement(episode, "rating")
rating_text = str(rating)
if rating_text != None:
Rating.text = rating_text
director = etree.SubElement(episode, "director")
director_text = myEp["director"]
if director_text != None:
director.text = director_text
credits = etree.SubElement(episode, "credits")
credits_text = myEp["writer"]
if credits_text != None:
credits.text = credits_text
cast = etree.SubElement(episode, "cast")
if getattr(myShow, "_actors", None) is not None:
for actor in myShow["_actors"]:
cur_actor_name_text = actor["name"]
if cur_actor_name_text != None and cur_actor_name_text.strip():
cur_actor = etree.SubElement(cast, "actor")
cur_actor.text = cur_actor_name_text.strip()
else:
# append data from (if any) related episodes
if curEpToWrite.name:
if not EpisodeName.text:
EpisodeName.text = curEpToWrite.name
else:
EpisodeName.text = EpisodeName.text + ", " + curEpToWrite.name
if curEpToWrite.description:
if not Overview.text:
Overview.text = curEpToWrite.description
else:
Overview.text = Overview.text + "\r" + curEpToWrite.description
helpers.indentXML(rootNode)
data = etree.ElementTree(rootNode)
return data