mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-12 10:11:07 +01:00
[ivi] Modernize
This commit is contained in:
parent
18b4e9e79d
commit
63be3b8989
@ -16,7 +16,7 @@
|
|||||||
class IviIE(InfoExtractor):
|
class IviIE(InfoExtractor):
|
||||||
IE_DESC = 'ivi.ru'
|
IE_DESC = 'ivi.ru'
|
||||||
IE_NAME = 'ivi'
|
IE_NAME = 'ivi'
|
||||||
_VALID_URL = r'https?://(?:www\.)?ivi\.ru/(?:watch/(?:[^/]+/)?|video/player\?.*?videoId=)(?P<videoid>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?ivi\.ru/(?:watch/(?:[^/]+/)?|video/player\?.*?videoId=)(?P<id>\d+)'
|
||||||
|
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
# Single movie
|
# Single movie
|
||||||
@ -63,13 +63,15 @@ def _extract_comment_count(self, html):
|
|||||||
return int(m.group('commentcount')) if m is not None else 0
|
return int(m.group('commentcount')) if m is not None else 0
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
video_id = self._match_id(url)
|
||||||
video_id = mobj.group('videoid')
|
|
||||||
|
|
||||||
api_url = 'http://api.digitalaccess.ru/api/json/'
|
api_url = 'http://api.digitalaccess.ru/api/json/'
|
||||||
|
|
||||||
data = {'method': 'da.content.get',
|
data = {
|
||||||
'params': [video_id, {'site': 's183',
|
'method': 'da.content.get',
|
||||||
|
'params': [
|
||||||
|
video_id, {
|
||||||
|
'site': 's183',
|
||||||
'referrer': 'http://www.ivi.ru/watch/%s' % video_id,
|
'referrer': 'http://www.ivi.ru/watch/%s' % video_id,
|
||||||
'contentid': video_id
|
'contentid': video_id
|
||||||
}
|
}
|
||||||
@ -78,14 +80,17 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
request = compat_urllib_request.Request(api_url, json.dumps(data))
|
request = compat_urllib_request.Request(api_url, json.dumps(data))
|
||||||
|
|
||||||
video_json_page = self._download_webpage(request, video_id, 'Downloading video JSON')
|
video_json_page = self._download_webpage(
|
||||||
|
request, video_id, 'Downloading video JSON')
|
||||||
video_json = json.loads(video_json_page)
|
video_json = json.loads(video_json_page)
|
||||||
|
|
||||||
if 'error' in video_json:
|
if 'error' in video_json:
|
||||||
error = video_json['error']
|
error = video_json['error']
|
||||||
if error['origin'] == 'NoRedisValidData':
|
if error['origin'] == 'NoRedisValidData':
|
||||||
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
||||||
raise ExtractorError('Unable to download video %s: %s' % (video_id, error['message']), expected=True)
|
raise ExtractorError(
|
||||||
|
'Unable to download video %s: %s' % (video_id, error['message']),
|
||||||
|
expected=True)
|
||||||
|
|
||||||
result = video_json['result']
|
result = video_json['result']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user