From 2522a0b7dab3acde63ed1384d53a6e5c2b7fa749 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sergey=20M=E2=80=A4?= Date: Fri, 2 Jan 2015 22:28:48 +0600 Subject: [PATCH] [kontrtube] Extract display_id Trailing slash in URL is mandatory now --- youtube_dl/extractor/kontrtube.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/kontrtube.py b/youtube_dl/extractor/kontrtube.py index 41fd62009..720bc939b 100644 --- a/youtube_dl/extractor/kontrtube.py +++ b/youtube_dl/extractor/kontrtube.py @@ -10,13 +10,14 @@ 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', @@ -28,21 +29,28 @@ 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) + 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') + description = self._html_search_meta( + 'description', webpage, 'video description') mobj = re.search( - r'
Длительность: (?P\d+)м:(?P\d+)с
', webpage) + 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) + r'
Просмотров: (\d+)
', + webpage, 'view count', fatal=False) comment_count = None comment_str = self._html_search_regex( @@ -56,6 +64,7 @@ class KontrTubeIE(InfoExtractor): return { 'id': video_id, + 'display_id': display_id, 'url': video_url, 'thumbnail': thumbnail, 'title': title, -- 2.22.2