summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRemita Amine <[email protected]>2020-12-29 14:09:10 +0100
committerRemita Amine <[email protected]>2020-12-29 14:11:37 +0100
commitc931c4b8ddb32371cddf48ea52d0c036a6a66240 (patch)
tree418cda9e2c80eb5179d05f5d241120ce2742f0d0
parent7acd042bbb555962f42fa4f0f236772194d2da64 (diff)
downloadyoutube-dl-c931c4b8ddb32371cddf48ea52d0c036a6a66240.tar.gz
youtube-dl-c931c4b8ddb32371cddf48ea52d0c036a6a66240.zip
[sevenplay] detect API errors
-rw-r--r--youtube_dl/extractor/sevenplus.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/youtube_dl/extractor/sevenplus.py b/youtube_dl/extractor/sevenplus.py
index 84568ac69..240afc18f 100644
--- a/youtube_dl/extractor/sevenplus.py
+++ b/youtube_dl/extractor/sevenplus.py
@@ -4,8 +4,12 @@ from __future__ import unicode_literals
import re
from .brightcove import BrightcoveNewIE
-from ..compat import compat_str
+from ..compat import (
+ compat_HTTPError,
+ compat_str,
+)
from ..utils import (
+ ExtractorError,
try_get,
update_url_query,
)
@@ -41,16 +45,22 @@ class SevenPlusIE(BrightcoveNewIE):
def _real_extract(self, url):
path, episode_id = re.match(self._VALID_URL, url).groups()
- media = self._download_json(
- 'https://videoservice.swm.digital/playback', episode_id, query={
- 'appId': '7plus',
- 'deviceType': 'web',
- 'platformType': 'web',
- 'accountId': 5303576322001,
- 'referenceId': 'ref:' + episode_id,
- 'deliveryId': 'csai',
- 'videoType': 'vod',
- })['media']
+ try:
+ media = self._download_json(
+ 'https://videoservice.swm.digital/playback', episode_id, query={
+ 'appId': '7plus',
+ 'deviceType': 'web',
+ 'platformType': 'web',
+ 'accountId': 5303576322001,
+ 'referenceId': 'ref:' + episode_id,
+ 'deliveryId': 'csai',
+ 'videoType': 'vod',
+ })['media']
+ except ExtractorError as e:
+ if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
+ raise ExtractorError(self._parse_json(
+ e.cause.read().decode(), episode_id)[0]['error_code'], expected=True)
+ raise
for source in media.get('sources', {}):
src = source.get('src')