Skip to content

Commit

Permalink
[ruutu] Authenticate format URLs (closes ytdl-org#21031, closes ytdl-…
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw authored and ThirumalaiK committed Jan 28, 2021
1 parent 648e416 commit b198690
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions youtube_dl/extractor/ruutu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
determine_ext,
ExtractorError,
int_or_none,
url_or_none,
xpath_attr,
xpath_text,
)
Expand Down Expand Up @@ -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 = []
Expand All @@ -114,9 +116,18 @@ def extract_formats(node):
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))
Expand Down

0 comments on commit b198690

Please sign in to comment.