X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Ftvigle.py;h=102362b295450f58ff085ec9be7d21921a1ac494;hb=c4a21bc9db1868e8be114f496899f6786b9982ec;hp=e81ade70799ba598d894f3e457cbb47dff825b18;hpb=a3b6be104d4da99b38942a9569a953cd2dc5a6fa;p=youtube-dl diff --git a/youtube_dl/extractor/tvigle.py b/youtube_dl/extractor/tvigle.py index e81ade707..102362b29 100644 --- a/youtube_dl/extractor/tvigle.py +++ b/youtube_dl/extractor/tvigle.py @@ -6,27 +6,27 @@ import re from .common import InfoExtractor from ..utils import ( float_or_none, - str_to_int, + parse_age_limit, ) class TvigleIE(InfoExtractor): IE_NAME = 'tvigle' IE_DESC = 'Интернет-телевидение Tvigle.ru' - _VALID_URL = r'http://(?:www\.)?tvigle\.ru/(?:[^/]+/)+(?P[^/]+)/$' + _VALID_URL = r'https?://(?:www\.)?(?:tvigle\.ru/(?:[^/]+/)+(?P[^/]+)/$|cloud\.tvigle\.ru/video/(?P\d+))' _TESTS = [ { - 'url': 'http://www.tvigle.ru/video/brat/', - 'md5': 'ff4344a4894b0524441fb6f8218dc716', + 'url': 'http://www.tvigle.ru/video/sokrat/', + 'md5': '36514aed3657d4f70b4b2cef8eb520cd', 'info_dict': { - 'id': '5118490', - 'display_id': 'brat', - 'ext': 'mp4', - 'title': 'Брат', - 'description': 'md5:d16ac7c0b47052ea51fddb92c4e413eb', - 'duration': 5722.6, - 'age_limit': 16, + 'id': '1848932', + 'display_id': 'sokrat', + 'ext': 'flv', + 'title': 'Сократ', + 'description': 'md5:a05bd01be310074d5833efc6743be95e', + 'duration': 6586, + 'age_limit': 0, }, }, { @@ -40,17 +40,22 @@ class TvigleIE(InfoExtractor): 'duration': 186.080, 'age_limit': 0, }, - }, + }, { + 'url': 'https://cloud.tvigle.ru/video/5267604/', + 'only_matching': True, + } ] 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, display_id) - - video_id = self._html_search_regex( - r'
  • ', webpage, 'video id') + if not video_id: + webpage = self._download_webpage(url, display_id) + video_id = self._html_search_regex( + r'
  • ', + webpage, 'video id') video_data = self._download_json( 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id) @@ -60,8 +65,8 @@ class TvigleIE(InfoExtractor): title = item['title'] description = item['description'] thumbnail = item['thumbnail'] - duration = float_or_none(item['durationMilliseconds'], 1000) - age_limit = str_to_int(item['ageRestrictions']) + duration = float_or_none(item.get('durationMilliseconds'), 1000) + age_limit = parse_age_limit(item.get('ageRestrictions')) formats = [] for vcodec, fmts in item['videos'].items(): @@ -71,6 +76,7 @@ class TvigleIE(InfoExtractor): 'format_id': '%s-%s' % (vcodec, quality), 'vcodec': vcodec, 'height': int(quality[:-1]), + 'filesize': item['video_files_size'][vcodec][quality], }) self._sort_formats(formats) @@ -83,4 +89,4 @@ class TvigleIE(InfoExtractor): 'duration': duration, 'age_limit': age_limit, 'formats': formats, - } \ No newline at end of file + }