本文整理汇总了Python中Network.fetch_xml方法的典型用法代码示例。如果您正苦于以下问题:Python Network.fetch_xml方法的具体用法?Python Network.fetch_xml怎么用?Python Network.fetch_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.fetch_xml方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_by_tvrage_string
# 需要导入模块: import Network [as 别名]
# 或者: from Network import fetch_xml [as 别名]
def search_by_tvrage_string(self):
"""
Search using TVRage's search API, with a string show name input.
If it matches exactly (ignoring hyphens), then consider it a 100% match.
Otherwise, score each potential match starting from the start_score.
"""
for show_name in self.show_names:
url = tvrage.SEARCH_URL % String.Quote(show_name, True)
xml = Network.fetch_xml(url)
i = 0
for show_xml in xml.xpath("//show"):
i += 1
result_show = str(show_xml.xpath("./name")[0].text)
if tvrage.sanitize_show_name(show_name) == tvrage.sanitize_show_name(result_show):
Log("Found exact match in title %s" % result_show)
score = 100
else:
score = self.start_score - i
nextResult = MetadataSearchResult(id=str(show_xml.xpath("./showid")[0].text),
name=result_show,
year=show_xml.xpath("./started")[0].text,
score=score,
lang=self.lang)
self.results.Append(nextResult)
Log(repr(nextResult))
示例2: search_by_tvrage_id
# 需要导入模块: import Network [as 别名]
# 或者: from Network import fetch_xml [as 别名]
def search_by_tvrage_id(self):
"""
If the show input is an integer, search by TVRage ID first, scoring the result using start_score.
"""
if len(self.show_names) == 1 and self.show_names[0].isdigit():
xml = Network.fetch_xml(tvrage.SHOW_INFO_URL % self.show_names[0])
if xml:
result = MetadataSearchResult(id=str(xml.xpath("/Showinfo/showid")[0].text),
name=str(xml.xpath("/Showinfo/showname")[0].text),
year=xml.xpath("/Showinfo/started")[0].text,
score=self.start_score,
lang=self.lang)
self.results.Append(result)
Log(repr(result))
示例3: update
# 需要导入模块: import Network [as 别名]
# 或者: from Network import fetch_xml [as 别名]
def update(self):
"""
Fetches the detailed episode info for all seasons and updates each season's metadata.
"""
Log("update %s: START" % self.tvrage_id)
xml = Network.fetch_xml(tvrage.EPISODE_LIST_URL % self.tvrage_id)
if xml:
for season_xml in xml.xpath("/Show/Episodelist/Season"):
self.update_season(season_xml)
else:
Log("no xml response from tvrage")
Log("update: END")
示例4: update
# 需要导入模块: import Network [as 别名]
# 或者: from Network import fetch_xml [as 别名]
def update(self):
Log("update %s: START" % self.tvrage_id)
xml = Network.fetch_xml(tvrage.SHOW_INFO_URL % self.tvrage_id)
self.metadata.title = xml.xpath("/Showinfo/showname")[0].text
if xml.xpath("/Showinfo/network"):
self.metadata.studio = xml.xpath("/Showinfo/network")[0].text
self.metadata.duration = int(xml.xpath("/Showinfo/runtime")[0].text) * 60 * 1000
self.metadata.originally_available_at = Datetime.ParseDate(xml.xpath("/Showinfo/started")[0].text).date()
self.metadata.genres = [genre.text for genre in xml.xpath("/Showinfo/genres/genre")]
if xml.xpath("/Showinfo/summary"):
self.metadata.summary = xml.xpath("/Showinfo/summary")[0].text
self.metadata.countries = [xml.xpath("/Showinfo/origin_country")[0].text]
self.metadata.tags = [xml.xpath("/Showinfo/classification")[0].text]
self.update_seasons(self.metadata, self.media)
self.update_images(self.metadata, self.media, xml)
Log("update: END")
示例5: check_alternate_titles
# 需要导入模块: import Network [as 别名]
# 或者: from Network import fetch_xml [as 别名]
def check_alternate_titles(self):
"""
Checks up to the top MAX_ALTERNATE_TITLE_SEARCHES regular matches to see if we match an alternate title.
"""
self.results.Sort('score', descending=True)
top_match_counter = 0
for result in self.results:
top_match_counter += 1
if result.score == 100:
return
elif top_match_counter <= MAX_ALTERNATE_TITLE_SEARCHES:
xml = Network.fetch_xml(tvrage.SHOW_INFO_URL % result.id)
if xml:
for aka_xml in xml.xpath("./akas/aka"):
for show_name in self.show_names:
aka_show_name = str(aka_xml.text)
Log("[%s] [%s]" %
(tvrage.sanitize_show_name(show_name), tvrage.sanitize_show_name(aka_show_name)))
if tvrage.sanitize_show_name(show_name) == tvrage.sanitize_show_name(aka_show_name):
Log("Found exact match in alternate title %s" % aka_show_name)
result.score = 100
示例6: fetch_banner_data
# 需要导入模块: import Network [as 别名]
# 或者: from Network import fetch_xml [as 别名]
def fetch_banner_data(self):
if self.tvdb_id is not None:
xml = Network.fetch_xml(TVDB_BANNER_LIST_URL % self.tvdb_id)
if xml:
return xml.xpath("/Banners/Banner")
return []