-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Heise] Add support for new c't uplink episodes #14108
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f19b07f
[Heise] Add support for new c't uplink episodes
36d79d4
[Heise] Remove code duplications for PR #14108
5da9553
[Heise] Add audio rss, resolve url redirects
1721d4a
[Heise] Improve RSS download for PR #14108
2377941
[heise] Further improve RSS download
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
xpath_text, | ||
) | ||
|
||
import re | ||
|
||
|
||
class HeiseIE(InfoExtractor): | ||
_VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html' | ||
|
@@ -25,6 +27,14 @@ class HeiseIE(InfoExtractor): | |
'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20', | ||
'thumbnail': r're:^https?://.*/gallery/$', | ||
} | ||
}, { | ||
'url': 'https://www.heise.de/ct/artikel/c-t-uplink-18-5-Android-Oreo-Nokia-Galaxy-Note-8-AMD-Ryzen-Threadripper-3812972.html',# noqa | ||
'info_dict': { | ||
'id': '3812972', | ||
'ext': 'mp4', | ||
'title': "c't uplink 18.5: Android Oreo, Nokia, Galaxy Note 8, AMD Ryzen Threadripper",# noqa | ||
'description': 'md5:0601ade34ae5c4f5058d378327928348' | ||
} | ||
}, { | ||
'url': 'http://www.heise.de/ct/artikel/c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2403911.html', | ||
'only_matching': True, | ||
|
@@ -53,11 +63,20 @@ def _real_extract(self, url): | |
r'<div[^>]+class="videoplayerjw"[^>]+data-title="([^"]+)"', | ||
webpage, 'title') | ||
|
||
doc = self._download_xml( | ||
'http://www.heise.de/videout/feed', video_id, query={ | ||
'container': container_id, | ||
'sequenz': sequenz_id, | ||
}) | ||
# videout/feed still and exlusively works for older videos | ||
# for new ct uplink episodes, whe need the work-around below. | ||
try: | ||
doc = self._download_xml( | ||
'http://www.heise.de/videout/feed', video_id, query={ | ||
'container': container_id, | ||
'sequenz': sequenz_id, | ||
}) | ||
except Exception as e: | ||
if e.cause.code == 404: | ||
if title.rfind('c\'t') != -1: | ||
return self.ctUplinkHelper(title, video_id) | ||
else: | ||
raise e | ||
|
||
formats = [] | ||
for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'): | ||
|
@@ -88,3 +107,51 @@ def _real_extract(self, url): | |
self._html_search_meta('date', webpage)), | ||
'formats': formats, | ||
} | ||
|
||
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( | ||
'https://blog.ct.de/ctuplink/ctuplinkvideo.rss', | ||
video_id, "Downloading alternative XML (SD)") | ||
hd_rss_feed = self._download_xml( | ||
'https://blog.ct.de/ctuplink/ctuplinkvideohd.rss', | ||
video_id, "Downloading alternative XML (HD)") | ||
|
||
titles = hd_rss_feed.findall('./channel/item/title') | ||
descriptions = hd_rss_feed.findall('./channel/item/description') | ||
|
||
sd_video_urls = sd_rss_feed.findall('./channel/item/guid') | ||
hd_video_urls = hd_rss_feed.findall('./channel/item/guid') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code duplication. |
||
|
||
# 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 | ||
for index, item in enumerate(titles): | ||
if titles[index].text.rfind(episode_str[0]) != -1: | ||
episode_index = index | ||
break | ||
|
||
# in case something went wrong | ||
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}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code duplication. |
||
|
||
self._sort_formats(formats) | ||
|
||
return { | ||
'id': video_id, | ||
'title': title, | ||
'description': descriptions[episode_index].text, | ||
'formats': formats | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplication.