mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-17 18:06:05 -05:00
[rutube] Use _download_json
This commit is contained in:
parent
0479c625a4
commit
18c95c1ab0
@ -2,7 +2,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import json
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
@ -40,15 +39,13 @@ class RutubeIE(InfoExtractor):
|
|||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
|
|
||||||
api_response = self._download_webpage(
|
video = self._download_json(
|
||||||
'http://rutube.ru/api/video/%s/?format=json' % video_id,
|
'http://rutube.ru/api/video/%s/?format=json' % video_id,
|
||||||
video_id, 'Downloading video JSON')
|
video_id, 'Downloading video JSON')
|
||||||
video = json.loads(api_response)
|
|
||||||
|
|
||||||
api_response = self._download_webpage(
|
trackinfo = self._download_json(
|
||||||
'http://rutube.ru/api/play/trackinfo/%s/?format=json' % video_id,
|
'http://rutube.ru/api/play/trackinfo/%s/?format=json' % video_id,
|
||||||
video_id, 'Downloading trackinfo JSON')
|
video_id, 'Downloading trackinfo JSON')
|
||||||
trackinfo = json.loads(api_response)
|
|
||||||
|
|
||||||
# Some videos don't have the author field
|
# Some videos don't have the author field
|
||||||
author = trackinfo.get('author') or {}
|
author = trackinfo.get('author') or {}
|
||||||
@ -82,10 +79,9 @@ class RutubeChannelIE(InfoExtractor):
|
|||||||
def _extract_videos(self, channel_id, channel_title=None):
|
def _extract_videos(self, channel_id, channel_title=None):
|
||||||
entries = []
|
entries = []
|
||||||
for pagenum in itertools.count(1):
|
for pagenum in itertools.count(1):
|
||||||
api_response = self._download_webpage(
|
page = self._download_json(
|
||||||
self._PAGE_TEMPLATE % (channel_id, pagenum),
|
self._PAGE_TEMPLATE % (channel_id, pagenum),
|
||||||
channel_id, 'Downloading page %s' % pagenum)
|
channel_id, 'Downloading page %s' % pagenum)
|
||||||
page = json.loads(api_response)
|
|
||||||
results = page['results']
|
results = page['results']
|
||||||
if not results:
|
if not results:
|
||||||
break
|
break
|
||||||
@ -111,10 +107,9 @@ class RutubeMovieIE(RutubeChannelIE):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
movie_id = mobj.group('id')
|
movie_id = mobj.group('id')
|
||||||
api_response = self._download_webpage(
|
movie = self._download_json(
|
||||||
self._MOVIE_TEMPLATE % movie_id, movie_id,
|
self._MOVIE_TEMPLATE % movie_id, movie_id,
|
||||||
'Downloading movie JSON')
|
'Downloading movie JSON')
|
||||||
movie = json.loads(api_response)
|
|
||||||
movie_name = movie['name']
|
movie_name = movie['name']
|
||||||
return self._extract_videos(movie_id, movie_name)
|
return self._extract_videos(movie_id, movie_name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user