diff options
author | Naglis Jonaitis <njonaitis@gmail.com> | 2015-02-14 17:48:04 +0200 |
---|---|---|
committer | Naglis Jonaitis <njonaitis@gmail.com> | 2015-02-14 17:48:04 +0200 |
commit | a294bce82f84482091fa6f44ce913a7a86fe8be8 (patch) | |
tree | 794a588b51acbeb4b1af97142cb59b8c92c1a098 /youtube_dl | |
parent | 76d1466b08d4e3cebc40a7fb7dae957c3b34b1eb (diff) |
[streamcz] Fix extraction (Closes #4940)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/streamcz.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/youtube_dl/extractor/streamcz.py b/youtube_dl/extractor/streamcz.py index c3ceb5f76..e92b93285 100644 --- a/youtube_dl/extractor/streamcz.py +++ b/youtube_dl/extractor/streamcz.py @@ -1,14 +1,30 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import hashlib +import time + from .common import InfoExtractor +from ..compat import ( + compat_urllib_request, +) from ..utils import ( int_or_none, ) +def _get_api_key(api_path): + if api_path.endswith('?'): + api_path = api_path[:-1] + + api_key = 'fb5f58a820353bd7095de526253c14fd' + a = '{0:}{1:}{2:}'.format(api_key, api_path, int(round(time.time() / 24 / 3600))) + return hashlib.md5(a.encode('ascii')).hexdigest() + + class StreamCZIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?stream\.cz/.+/(?P<id>[0-9]+)' + _API_URL = 'http://www.stream.cz/API' _TESTS = [{ 'url': 'http://www.stream.cz/peklonataliri/765767-ecka-pro-deti', @@ -36,8 +52,11 @@ class StreamCZIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - data = self._download_json( - 'http://www.stream.cz/API/episode/%s' % video_id, video_id) + api_path = '/episode/%s' % video_id + + req = compat_urllib_request.Request(self._API_URL + api_path) + req.add_header('Api-Password', _get_api_key(api_path)) + data = self._download_json(req, video_id) formats = [] for quality, video in enumerate(data['video_qualities']): |