[sevenplay] detect API errors
This commit is contained in:
parent
7acd042bbb
commit
c931c4b8dd
1 changed files with 21 additions and 11 deletions
|
@ -4,8 +4,12 @@ from __future__ import unicode_literals
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .brightcove import BrightcoveNewIE
|
from .brightcove import BrightcoveNewIE
|
||||||
from ..compat import compat_str
|
from ..compat import (
|
||||||
|
compat_HTTPError,
|
||||||
|
compat_str,
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
try_get,
|
try_get,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
)
|
)
|
||||||
|
@ -41,16 +45,22 @@ class SevenPlusIE(BrightcoveNewIE):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
path, episode_id = re.match(self._VALID_URL, url).groups()
|
path, episode_id = re.match(self._VALID_URL, url).groups()
|
||||||
|
|
||||||
media = self._download_json(
|
try:
|
||||||
'https://videoservice.swm.digital/playback', episode_id, query={
|
media = self._download_json(
|
||||||
'appId': '7plus',
|
'https://videoservice.swm.digital/playback', episode_id, query={
|
||||||
'deviceType': 'web',
|
'appId': '7plus',
|
||||||
'platformType': 'web',
|
'deviceType': 'web',
|
||||||
'accountId': 5303576322001,
|
'platformType': 'web',
|
||||||
'referenceId': 'ref:' + episode_id,
|
'accountId': 5303576322001,
|
||||||
'deliveryId': 'csai',
|
'referenceId': 'ref:' + episode_id,
|
||||||
'videoType': 'vod',
|
'deliveryId': 'csai',
|
||||||
})['media']
|
'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', {}):
|
for source in media.get('sources', {}):
|
||||||
src = source.get('src')
|
src = source.get('src')
|
||||||
|
|
Loading…
Reference in a new issue