[Heise] Remove code duplications for PR #14108
This commit is contained in:
parent
f19b07f6be
commit
36d79d4a3d
@ -109,43 +109,37 @@ class HeiseIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def ctUplinkHelper(self, title, video_id):
|
def ctUplinkHelper(self, title, video_id):
|
||||||
formats = []
|
|
||||||
|
|
||||||
# e.g. "18.5" from "c't uplink 18.5:"
|
# e.g. "18.5" from "c't uplink 18.5:"
|
||||||
episode_str = re.findall(r'[0-9]{1,2}.[0-9]{1,2}', title)
|
episode_str = re.findall(r'[0-9]{1,2}.[0-9]{1,2}', title)
|
||||||
|
|
||||||
sd_rss_feed = self._download_xml(
|
feeds = [
|
||||||
|
self._download_xml(
|
||||||
'https://blog.ct.de/ctuplink/ctuplinkvideo.rss',
|
'https://blog.ct.de/ctuplink/ctuplinkvideo.rss',
|
||||||
video_id, "Downloading alternative XML (SD)")
|
video_id, "Downloading alternative XML (SD)"),
|
||||||
hd_rss_feed = self._download_xml(
|
self._download_xml(
|
||||||
'https://blog.ct.de/ctuplink/ctuplinkvideohd.rss',
|
'https://blog.ct.de/ctuplink/ctuplinkvideohd.rss',
|
||||||
video_id, "Downloading alternative XML (HD)")
|
video_id, "Downloading alternative XML (HD)")]
|
||||||
|
|
||||||
titles = hd_rss_feed.findall('./channel/item/title')
|
titles = feeds[0].findall('./channel/item/title')
|
||||||
descriptions = hd_rss_feed.findall('./channel/item/description')
|
descriptions = feeds[0].findall('./channel/item/description')
|
||||||
|
|
||||||
sd_video_urls = sd_rss_feed.findall('./channel/item/guid')
|
# try to find the real matching title.
|
||||||
hd_video_urls = hd_rss_feed.findall('./channel/item/guid')
|
# only rely on the episode_str, e.g. "18.5".
|
||||||
|
|
||||||
# try to find the real matching title. it might be misformatted or so.
|
|
||||||
# thereby only rely on the episode_str, e.g. "18.5"
|
|
||||||
episode_index = -1
|
episode_index = -1
|
||||||
for index, item in enumerate(titles):
|
for index, item in enumerate(titles):
|
||||||
if titles[index].text.rfind(episode_str[0]) != -1:
|
if titles[index].text.rfind(episode_str[0]) != -1:
|
||||||
episode_index = index
|
episode_index = index
|
||||||
break
|
break
|
||||||
|
|
||||||
# in case something went wrong
|
# in case episode not found at all
|
||||||
if episode_index == -1:
|
if episode_index == -1:
|
||||||
return
|
return
|
||||||
|
|
||||||
formats.append({
|
formats = []
|
||||||
'url': sd_video_urls[episode_index].text,
|
for feed in feeds:
|
||||||
'height': 360})
|
formats.append({
|
||||||
|
'url': feed.findall('./channel/item/guid')[episode_index].text,
|
||||||
formats.append({
|
'ext': 'mp4'})
|
||||||
'url': hd_video_urls[episode_index].text,
|
|
||||||
'height': 720})
|
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user