From 36d79d4a3ddfb024d23c354dd7f0f121275e5eb0 Mon Sep 17 00:00:00 2001 From: Kay B <> Date: Sun, 17 Sep 2017 22:55:52 +0200 Subject: [PATCH] [Heise] Remove code duplications for PR #14108 --- youtube_dl/extractor/heise.py | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/youtube_dl/extractor/heise.py b/youtube_dl/extractor/heise.py index 72430258d..991e6520c 100644 --- a/youtube_dl/extractor/heise.py +++ b/youtube_dl/extractor/heise.py @@ -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)