aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/eagleplatform.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2017-07-09 15:57:33 +0700
committerSergey M․ <dstftw@gmail.com>2017-07-09 15:57:58 +0700
commit665e9452461abaff7127653265c78bd585acea6c (patch)
treedd9df80f3def57f8ff07448176ec631234d2095c /youtube_dl/extractor/eagleplatform.py
parent5af2fd7fa02734c2a23f917fb60f1c14da149d3d (diff)
[eagleplatform] Add support for referrer protected videos (closes #13557)
Diffstat (limited to 'youtube_dl/extractor/eagleplatform.py')
-rw-r--r--youtube_dl/extractor/eagleplatform.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/youtube_dl/extractor/eagleplatform.py b/youtube_dl/extractor/eagleplatform.py
index 5e1de04a1..34891a362 100644
--- a/youtube_dl/extractor/eagleplatform.py
+++ b/youtube_dl/extractor/eagleplatform.py
@@ -11,6 +11,7 @@ from ..compat import (
from ..utils import (
ExtractorError,
int_or_none,
+ unsmuggle_url,
)
@@ -50,6 +51,10 @@ class EaglePlatformIE(InfoExtractor):
'view_count': int,
},
'skip': 'Georestricted',
+ }, {
+ # referrer protected video (https://tvrain.ru/lite/teleshow/kak_vse_nachinalos/namin-418921/)
+ 'url': 'tvrainru.media.eagleplatform.com:582306',
+ 'only_matching': True,
}]
@staticmethod
@@ -103,9 +108,10 @@ class EaglePlatformIE(InfoExtractor):
if status != 200:
raise ExtractorError(' '.join(response['errors']), expected=True)
- def _download_json(self, url_or_request, video_id, note='Downloading JSON metadata', *args, **kwargs):
+ def _download_json(self, url_or_request, video_id, *args, **kwargs):
try:
- response = super(EaglePlatformIE, self)._download_json(url_or_request, video_id, note)
+ response = super(EaglePlatformIE, self)._download_json(
+ url_or_request, video_id, *args, **kwargs)
except ExtractorError as ee:
if isinstance(ee.cause, compat_HTTPError):
response = self._parse_json(ee.cause.read().decode('utf-8'), video_id)
@@ -117,11 +123,24 @@ class EaglePlatformIE(InfoExtractor):
return self._download_json(url_or_request, video_id, note)['data'][0]
def _real_extract(self, url):
+ url, smuggled_data = unsmuggle_url(url, {})
+
mobj = re.match(self._VALID_URL, url)
host, video_id = mobj.group('custom_host') or mobj.group('host'), mobj.group('id')
+ headers = {}
+ query = {
+ 'id': video_id,
+ }
+
+ referrer = smuggled_data.get('referrer')
+ if referrer:
+ headers['Referer'] = referrer
+ query['referrer'] = referrer
+
player_data = self._download_json(
- 'http://%s/api/player_data?id=%s' % (host, video_id), video_id)
+ 'http://%s/api/player_data' % host, video_id,
+ headers=headers, query=query)
media = player_data['data']['playlist']['viewports'][0]['medialist'][0]