X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fkontrtube.py;h=720bc939bfd4c3a30c9a3709968c6008e6472067;hb=385f8ae4684e7c7fd04d66b6066d980c93e2d79f;hp=1b45b67b0579d9fb06462f587651bc8f83e4751d;hpb=18395217c489f1b324ea7b85305f8b2edaf237c9;p=youtube-dl diff --git a/youtube_dl/extractor/kontrtube.py b/youtube_dl/extractor/kontrtube.py index 1b45b67b0..720bc939b 100644 --- a/youtube_dl/extractor/kontrtube.py +++ b/youtube_dl/extractor/kontrtube.py @@ -4,18 +4,20 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..utils import int_or_none class KontrTubeIE(InfoExtractor): IE_NAME = 'kontrtube' IE_DESC = 'KontrTube.ru - Труба зовёт' - _VALID_URL = r'http://(?:www\.)?kontrtube\.ru/videos/(?P\d+)/.+' + _VALID_URL = r'http://(?:www\.)?kontrtube\.ru/videos/(?P\d+)/(?P[^/]+)/' _TEST = { 'url': 'http://www.kontrtube.ru/videos/2678/nad-olimpiyskoy-derevney-v-sochi-podnyat-rossiyskiy-flag/', 'md5': '975a991a4926c9a85f383a736a2e6b80', 'info_dict': { 'id': '2678', + 'display_id': 'nad-olimpiyskoy-derevney-v-sochi-podnyat-rossiyskiy-flag', 'ext': 'mp4', 'title': 'Над олимпийской деревней в Сочи поднят российский флаг', 'description': 'md5:80edc4c613d5887ae8ccf1d59432be41', @@ -27,40 +29,47 @@ class KontrTubeIE(InfoExtractor): def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') + display_id = mobj.group('display_id') - webpage = self._download_webpage(url, video_id, 'Downloading page') + webpage = self._download_webpage( + url, display_id, 'Downloading page') - video_url = self._html_search_regex(r"video_url: '(.+?)/?',", webpage, 'video URL') - thumbnail = self._html_search_regex(r"preview_url: '(.+?)/?',", webpage, 'video thumbnail', fatal=False) - title = self._html_search_regex(r'(.+?) - Труба зовёт - Интересный видеохостинг', webpage, - 'video title') - description = self._html_search_meta('description', webpage, 'video description') + video_url = self._html_search_regex( + r"video_url\s*:\s*'(.+?)/?',", webpage, 'video URL') + thumbnail = self._html_search_regex( + r"preview_url\s*:\s*'(.+?)/?',", webpage, 'video thumbnail', fatal=False) + title = self._html_search_regex( + r'(.+?)', webpage, 'video title') + description = self._html_search_meta( + 'description', webpage, 'video description') - mobj = re.search(r'
Длительность: (?P\d+)м:(?P\d+)с
', + mobj = re.search( + r'
Длительность: (?P\d+)м:(?P\d+)с
', webpage) duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None - view_count = self._html_search_regex(r'
Просмотров: (\d+)
', webpage, - 'view count', fatal=False) - view_count = int(view_count) if view_count is not None else None + view_count = self._html_search_regex( + r'
Просмотров: (\d+)
', + webpage, 'view count', fatal=False) comment_count = None - comment_str = self._html_search_regex(r'Комментарии: ([^<]+)', webpage, 'comment count', - fatal=False) + comment_str = self._html_search_regex( + r'Комментарии: ([^<]+)', webpage, 'comment count', fatal=False) if comment_str.startswith('комментариев нет'): comment_count = 0 else: mobj = re.search(r'\d+ из (?P\d+) комментариев', comment_str) if mobj: - comment_count = int(mobj.group('total')) + comment_count = mobj.group('total') return { 'id': video_id, + 'display_id': display_id, 'url': video_url, 'thumbnail': thumbnail, 'title': title, 'description': description, 'duration': duration, - 'view_count': view_count, - 'comment_count': comment_count, - } \ No newline at end of file + 'view_count': int_or_none(view_count), + 'comment_count': int_or_none(comment_count), + }