1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-22 00:43:01 +08:00

[rutube] Simplify

This commit is contained in:
Philipp Hagemeister 2014-01-28 03:32:07 +01:00
parent 4857beba3a
commit 37e3b90d59

View File

@ -76,15 +76,16 @@ class RutubeChannelIE(InfoExtractor):
def _extract_videos(self, channel_id, channel_title=None):
entries = []
for pagenum in itertools.count(1):
api_response = self._download_webpage(self._PAGE_TEMPLATE % (channel_id, pagenum),
api_response = self._download_webpage(
self._PAGE_TEMPLATE % (channel_id, pagenum),
channel_id, 'Downloading page %s' % pagenum)
page = json.loads(api_response)
results = page['results']
if len(results) == 0:
break;
if not results:
break
entries.extend(self.url_result(result['video_url'], 'Rutube') for result in results)
if page['has_next'] is False:
break;
if not page['has_next']:
break
return self.playlist_result(entries, channel_id, channel_title)
def _real_extract(self, url):
@ -104,7 +105,8 @@ class RutubeMovieIE(RutubeChannelIE):
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
movie_id = mobj.group('id')
api_response = self._download_webpage(self._MOVIE_TEMPLATE % movie_id, movie_id,
api_response = self._download_webpage(
self._MOVIE_TEMPLATE % movie_id, movie_id,
'Downloading movie JSON')
movie = json.loads(api_response)
movie_name = movie['name']