mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2025-02-17 01:17:54 +01:00
[Pivotshare] Updated error handling
This commit is contained in:
parent
ed09f7cef0
commit
b892c5fbb7
@ -5,6 +5,7 @@ import re
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_urllib_parse_unquote
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
try_get,
|
try_get,
|
||||||
compat_str,
|
compat_str,
|
||||||
@ -129,10 +130,10 @@ class PivotshareIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
query={
|
query={
|
||||||
'client_id': self._CLIENT_ID
|
'client_id': self._CLIENT_ID
|
||||||
})
|
}, expected_status=401)
|
||||||
|
|
||||||
if login.get('errors'):
|
if login.get('errors'):
|
||||||
raise ExtractorError('Unable to login: %s' % clean_html(login['errors']), expected=True)
|
raise ExtractorError('Unable to login: %s' % clean_html(login['errors'][0]['message']), expected=True)
|
||||||
else:
|
else:
|
||||||
self._TOKEN = try_get(login, lambda x: x['login']['access_token'], compat_str)
|
self._TOKEN = try_get(login, lambda x: x['login']['access_token'], compat_str)
|
||||||
|
|
||||||
@ -166,14 +167,14 @@ class PivotshareIE(InfoExtractor):
|
|||||||
video_id, "Downloading media JSON metadata",
|
video_id, "Downloading media JSON metadata",
|
||||||
query=query)
|
query=query)
|
||||||
|
|
||||||
try:
|
stream_data = self._download_json(
|
||||||
stream_data = self._download_json(
|
'%schannels/%s/media/%s/stream' % (self._API_BASE, channel_id, video_id),
|
||||||
'%schannels/%s/media/%s/stream' % (self._API_BASE, channel_id, video_id),
|
video_id, "Downloading stream JSON metadata",
|
||||||
video_id, "Downloading stream JSON metadata",
|
query=query, expected_status=401)
|
||||||
query=query)
|
|
||||||
except ExtractorError:
|
if stream_data.get('errors'):
|
||||||
self.raise_login_required(
|
self.raise_login_required(
|
||||||
'This video is only available for %s subscribers' % channel)
|
'This video is only available for %s subscribers' % compat_urllib_parse_unquote(channel))
|
||||||
|
|
||||||
sources = try_get(
|
sources = try_get(
|
||||||
stream_data, lambda x: x['channel']['media']['stream']['formats'], list)
|
stream_data, lambda x: x['channel']['media']['stream']['formats'], list)
|
||||||
|
Loading…
Reference in New Issue
Block a user