[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):
|
||||
formats = []
|
||||
|
||||
# e.g. "18.5" from "c't uplink 18.5:"
|
||||
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',
|
||||
video_id, "Downloading alternative XML (SD)")
|
||||
hd_rss_feed = self._download_xml(
|
||||
video_id, "Downloading alternative XML (SD)"),
|
||||
self._download_xml(
|
||||
'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')
|
||||
descriptions = hd_rss_feed.findall('./channel/item/description')
|
||||
titles = feeds[0].findall('./channel/item/title')
|
||||
descriptions = feeds[0].findall('./channel/item/description')
|
||||
|
||||
sd_video_urls = sd_rss_feed.findall('./channel/item/guid')
|
||||
hd_video_urls = hd_rss_feed.findall('./channel/item/guid')
|
||||
|
||||
# try to find the real matching title. it might be misformatted or so.
|
||||
# thereby only rely on the episode_str, e.g. "18.5"
|
||||
# try to find the real matching title.
|
||||
# only rely on the episode_str, e.g. "18.5".
|
||||
episode_index = -1
|
||||
for index, item in enumerate(titles):
|
||||
if titles[index].text.rfind(episode_str[0]) != -1:
|
||||
episode_index = index
|
||||
break
|
||||
|
||||
# in case something went wrong
|
||||
# in case episode not found at all
|
||||
if episode_index == -1:
|
||||
return
|
||||
|
||||
formats.append({
|
||||
'url': sd_video_urls[episode_index].text,
|
||||
'height': 360})
|
||||
|
||||
formats.append({
|
||||
'url': hd_video_urls[episode_index].text,
|
||||
'height': 720})
|
||||
formats = []
|
||||
for feed in feeds:
|
||||
formats.append({
|
||||
'url': feed.findall('./channel/item/guid')[episode_index].text,
|
||||
'ext': 'mp4'})
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user