[rutube] Simplify

pull/8/head
Philipp Hagemeister 11 years ago
parent 4857beba3a
commit 37e3b90d59

@ -76,15 +76,16 @@ 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(self._PAGE_TEMPLATE % (channel_id, pagenum), api_response = self._download_webpage(
channel_id, 'Downloading page %s' % pagenum) self._PAGE_TEMPLATE % (channel_id, pagenum),
channel_id, 'Downloading page %s' % pagenum)
page = json.loads(api_response) page = json.loads(api_response)
results = page['results'] results = page['results']
if len(results) == 0: if not results:
break; break
entries.extend(self.url_result(result['video_url'], 'Rutube') for result in results) entries.extend(self.url_result(result['video_url'], 'Rutube') for result in results)
if page['has_next'] is False: if not page['has_next']:
break; break
return self.playlist_result(entries, channel_id, channel_title) return self.playlist_result(entries, channel_id, channel_title)
def _real_extract(self, url): def _real_extract(self, url):
@ -104,8 +105,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(self._MOVIE_TEMPLATE % movie_id, movie_id, api_response = self._download_webpage(
'Downloading movie JSON') self._MOVIE_TEMPLATE % movie_id, movie_id,
'Downloading movie JSON')
movie = json.loads(api_response) 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…
Cancel
Save