diff options
author | Sergey M․ <dstftw@gmail.com> | 2020-12-12 05:57:14 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2020-12-12 05:57:14 +0700 |
commit | 1e6f7f3b457d97271da648df8e0a8e1b6bb90a8c (patch) | |
tree | e4142af889c6490497313f2e7b1bd1f68370bccf | |
parent | 469ff02f4e288f5e2d10c8f9f6582ae9b63e924b (diff) | |
download | youtube-dl-1e6f7f3b457d97271da648df8e0a8e1b6bb90a8c.tar.xz |
[ruutu] Authenticate format URLs (closes #21031, closes #26782)
-rw-r--r-- | youtube_dl/extractor/ruutu.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/youtube_dl/extractor/ruutu.py b/youtube_dl/extractor/ruutu.py index af42e3b12..561669bb2 100644 --- a/youtube_dl/extractor/ruutu.py +++ b/youtube_dl/extractor/ruutu.py @@ -7,6 +7,7 @@ from ..utils import ( determine_ext, ExtractorError, int_or_none, + url_or_none, xpath_attr, xpath_text, ) @@ -92,12 +93,13 @@ class RuutuIE(InfoExtractor): 'only_matching': True, }, ] + _API_BASE = 'https://gatling.nelonenmedia.fi' def _real_extract(self, url): video_id = self._match_id(url) video_xml = self._download_xml( - 'https://gatling.nelonenmedia.fi/media-xml-cache', video_id, + '%s/media-xml-cache' % self._API_BASE, video_id, query={'id': video_id}) formats = [] @@ -114,9 +116,18 @@ class RuutuIE(InfoExtractor): continue processed_urls.append(video_url) ext = determine_ext(video_url) + auth_video_url = url_or_none(self._download_webpage( + '%s/auth/access/v2' % self._API_BASE, video_id, + note='Downloading authenticated %s stream URL' % ext, + fatal=False, query={'stream': video_url})) + if auth_video_url: + processed_urls.append(auth_video_url) + video_url = auth_video_url if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( - video_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) + video_url, video_id, 'mp4', + entry_protocol='m3u8_native', m3u8_id='hls', + fatal=False)) elif ext == 'f4m': formats.extend(self._extract_f4m_formats( video_url, video_id, f4m_id='hds', fatal=False)) |