projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[ubu] Add missing whitespace
[youtube-dl]
/
youtube_dl
/
extractor
/
rutube.py
diff --git
a/youtube_dl/extractor/rutube.py
b/youtube_dl/extractor/rutube.py
index 7c66074602521aea74f31da096be2c86a8281de8..357edbbdaf88c6c29395aa7878c18f305c79b216 100644
(file)
--- a/
youtube_dl/extractor/rutube.py
+++ b/
youtube_dl/extractor/rutube.py
@@
-2,7
+2,6
@@
from __future__ import unicode_literals
import re
from __future__ import unicode_literals
import re
-import json
import itertools
from .common import InfoExtractor
import itertools
from .common import InfoExtractor
@@
-39,20
+38,19
@@
class RutubeIE(InfoExtractor):
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
-
-
api_response = self._download_webpage
(
+
+
video = self._download_json
(
'http://rutube.ru/api/video/%s/?format=json' % video_id,
video_id, 'Downloading video JSON')
'http://rutube.ru/api/video/%s/?format=json' % video_id,
video_id, 'Downloading video JSON')
- video = json.loads(api_response)
-
- api_response = self._download_webpage(
- 'http://rutube.ru/api/play/trackinfo/%s/?format=json' % video_id,
- 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 {}
- m3u8_url = trackinfo['video_balancer'].get('m3u8')
+ author = video.get('author') or {}
+
+ options = self._download_json(
+ 'http://rutube.ru/api/play/options/%s/?format=json' % video_id,
+ video_id, 'Downloading options JSON')
+
+ m3u8_url = options['video_balancer'].get('m3u8')
if m3u8_url is None:
raise ExtractorError('Couldn\'t find m3u8 manifest url')
if m3u8_url is None:
raise ExtractorError('Couldn\'t find m3u8 manifest url')
@@
-82,10
+80,9
@@
class RutubeChannelIE(InfoExtractor):
def _extract_videos(self, channel_id, channel_title=None):
entries = []
for pagenum in itertools.count(1):
def _extract_videos(self, channel_id, channel_title=None):
entries = []
for pagenum in itertools.count(1):
-
api_response = self._download_webpage
(
+
page = self._download_json
(
self._PAGE_TEMPLATE % (channel_id, pagenum),
channel_id, 'Downloading page %s' % pagenum)
self._PAGE_TEMPLATE % (channel_id, pagenum),
channel_id, 'Downloading page %s' % pagenum)
- page = json.loads(api_response)
results = page['results']
if not results:
break
results = page['results']
if not results:
break
@@
-111,10
+108,9
@@
class RutubeMovieIE(RutubeChannelIE):
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
movie_id = mobj.group('id')
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
movie_id = mobj.group('id')
-
api_response = self._download_webpage
(
+
movie = self._download_json
(
self._MOVIE_TEMPLATE % movie_id, movie_id,
'Downloading movie JSON')
self._MOVIE_TEMPLATE % movie_id, movie_id,
'Downloading movie JSON')
- movie = json.loads(api_response)
movie_name = movie['name']
return self._extract_videos(movie_id, movie_name)
movie_name = movie['name']
return self._extract_videos(movie_id, movie_name)