From e3a9f32f52bbd9be8b38d70a529808f123126ce7 Mon Sep 17 00:00:00 2001 From: dst Date: Tue, 28 Jan 2014 08:47:17 +0700 Subject: [PATCH] [rutube] Add support for user videos --- youtube_dl/extractor/__init__.py | 3 ++- youtube_dl/extractor/rutube.py | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 19ca5d6b4..e89b5cf9d 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -164,7 +164,8 @@ from .rutube import ( RutubeIE, RutubeChannelIE, - RutubeMovieIE + RutubeMovieIE, + RutubePersonIE, ) from .servingsys import ServingSysIE from .sina import SinaIE diff --git a/youtube_dl/extractor/rutube.py b/youtube_dl/extractor/rutube.py index 6075296ff..9a20facfd 100644 --- a/youtube_dl/extractor/rutube.py +++ b/youtube_dl/extractor/rutube.py @@ -16,7 +16,7 @@ class RutubeIE(InfoExtractor): IE_NAME = 'rutube' IE_DESC = 'Rutube videos' - _VALID_URL = r'https?://rutube\.ru/video/(?P\w+)' + _VALID_URL = r'https?://rutube\.ru/video/(?P[\da-z]{32})' _TEST = { 'url': 'http://rutube.ru/video/3eac3b4561676c17df9132a9a1e62e3e/', @@ -34,14 +34,14 @@ class RutubeIE(InfoExtractor): def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) - long_id = mobj.group('long_id') + video_id = mobj.group('id') - api_response = self._download_webpage('http://rutube.ru/api/video/%s/?format=json' % long_id, - long_id, 'Downloading video JSON') + api_response = self._download_webpage('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' % long_id, - long_id, 'Downloading trackinfo JSON') + 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 @@ -108,4 +108,12 @@ def _real_extract(self, url): 'Downloading movie JSON') movie = json.loads(api_response) movie_name = movie['name'] - return self._extract_videos(movie_id, movie_name) \ No newline at end of file + return self._extract_videos(movie_id, movie_name) + + +class RutubePersonIE(RutubeChannelIE): + IE_NAME = 'rutube:person' + IE_DESC = 'Rutube person videos' + _VALID_URL = r'http://rutube\.ru/video/person/(?P\d+)' + + _PAGE_TEMPLATE = 'http://rutube.ru/api/video/person/%s/?page=%s&format=json' \ No newline at end of file