aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--youtube_dl/extractor/fox.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/youtube_dl/extractor/fox.py b/youtube_dl/extractor/fox.py
index 0ffceeb7c..f30d3cba8 100644
--- a/youtube_dl/extractor/fox.py
+++ b/youtube_dl/extractor/fox.py
@@ -6,10 +6,12 @@ import uuid
from .adobepass import AdobePassIE
from ..compat import (
+ compat_HTTPError,
compat_str,
compat_urllib_parse_unquote,
)
from ..utils import (
+ ExtractorError,
int_or_none,
parse_age_limit,
parse_duration,
@@ -48,6 +50,7 @@ class FOXIE(AdobePassIE):
'url': 'https://www.fox.com/watch/30056b295fb57f7452aeeb4920bc3024/',
'only_matching': True,
}]
+ _GEO_BYPASS = False
_HOME_PAGE_URL = 'https://www.fox.com/'
_API_KEY = 'abdcbed02c124d393b39e818a4312055'
_access_token = None
@@ -58,9 +61,22 @@ class FOXIE(AdobePassIE):
}
if self._access_token:
headers['Authorization'] = 'Bearer ' + self._access_token
- return self._download_json(
- 'https://api2.fox.com/v2.0/' + path,
- video_id, data=data, headers=headers)
+ try:
+ return self._download_json(
+ 'https://api2.fox.com/v2.0/' + path,
+ video_id, data=data, headers=headers)
+ except ExtractorError as e:
+ if isinstance(e.cause, compat_HTTPError) and e.cause.status == 403:
+ entitlement_issues = self._parse_json(
+ e.cause.read().decode(), video_id)['entitlementIssues']
+ for e in entitlement_issues:
+ if e.get('errorCode') == 1005:
+ raise ExtractorError(
+ 'This video is only available via cable service provider '
+ 'subscription. You may want to use --cookies.', expected=True)
+ messages = ', '.join([e['message'] for e in entitlement_issues])
+ raise ExtractorError(messages, expected=True)
+ raise
def _real_initialize(self):
if not self._access_token:
@@ -81,7 +97,15 @@ class FOXIE(AdobePassIE):
title = video['name']
release_url = video['url']
- m3u8_url = self._download_json(release_url, video_id)['playURL']
+ try:
+ m3u8_url = self._download_json(release_url, video_id)['playURL']
+ except ExtractorError as e:
+ if isinstance(e.cause, compat_HTTPError) and e.cause.status == 403:
+ error = self._parse_json(e.cause.read().decode(), video_id)
+ if error.get('exception') == 'GeoLocationBlocked':
+ self.raise_geo_restricted(countries=['US'])
+ raise ExtractorError(error['description'], expected=True)
+ raise
formats = self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls')