diff options
author | Remita Amine <remitamine@gmail.com> | 2018-07-01 22:32:59 +0100 |
---|---|---|
committer | Remita Amine <remitamine@gmail.com> | 2018-07-01 22:41:32 +0100 |
commit | 8cee692b8b66322e4c1a0d37baceb9e4c49a3f8e (patch) | |
tree | 5fb6c0f64df1911499b2c4230889f4e1a1432564 /youtube_dl/extractor | |
parent | 973b6ceebbf0c79086cbf3203a8a8c79daf0b1ba (diff) |
[go90] detect geo restriction error and pass geo verification headers(closes #16874)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/go90.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/youtube_dl/extractor/go90.py b/youtube_dl/extractor/go90.py index 35dde42d0..6f8c56a93 100644 --- a/youtube_dl/extractor/go90.py +++ b/youtube_dl/extractor/go90.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..compat import compat_HTTPError from ..utils import ( determine_ext, ExtractorError, @@ -28,14 +29,27 @@ class Go90IE(InfoExtractor): 'age_limit': 14, } } + _GEO_BYPASS = False def _real_extract(self, url): video_id = self._match_id(url) - video_data = self._download_json( - 'https://www.go90.com/api/view/items/' + video_id, - video_id, headers={ + + try: + headers = self.geo_verification_headers() + headers.update({ 'Content-Type': 'application/json; charset=utf-8', - }, data=b'{"client":"web","device_type":"pc"}') + }) + video_data = self._download_json( + 'https://www.go90.com/api/view/items/' + video_id, video_id, + headers=headers, data=b'{"client":"web","device_type":"pc"}') + except ExtractorError as e: + if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400: + message = self._parse_json(e.cause.read().decode(), None)['error']['message'] + if 'region unavailable' in message: + self.raise_geo_restricted(countries=['US']) + raise ExtractorError(message, expected=True) + raise + if video_data.get('requires_drm'): raise ExtractorError('This video is DRM protected.', expected=True) main_video_asset = video_data['main_video_asset'] |