2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_urlparse
13 class FirstTVIE(InfoExtractor):
15 IE_DESC = 'Первый канал'
16 _VALID_URL = r'https?://(?:www\.)?1tv\.ru/(?:[^/]+/)+(?P<id>[^/?#]+)'
19 'url': 'http://www.1tv.ru/shows/naedine-so-vsemi/vypuski/gost-lyudmila-senchina-naedine-so-vsemi-vypusk-ot-12-02-2015',
20 'md5': 'a1b6b60d530ebcf8daacf4565762bbaf',
24 'title': 'Гость Людмила Сенчина. Наедине со всеми. Выпуск от 12.02.2015',
25 'description': 'md5:36a39c1d19618fec57d12efe212a8370',
26 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$',
27 'upload_date': '20150212',
31 'url': 'http://www.1tv.ru/shows/dobroe-utro/pro-zdorove/vesennyaya-allergiya-dobroe-utro-fragment-vypuska-ot-07042016',
32 'only_matching': 'true',
35 def _real_extract(self, url):
36 display_id = self._match_id(url)
38 webpage = self._download_webpage(url, display_id)
39 playlist_url = compat_urlparse.urljoin(url, self._search_regex(
40 r'data-playlist-url="([^"]+)', webpage, 'playlist url'))
42 item = self._download_json(playlist_url, display_id)[0]
44 quality = qualities(('ld', 'sd', 'hd', ))
46 for f in item.get('mbr', []):
54 'quality': quality(fname),
56 self._sort_formats(formats)
58 title = self._html_search_regex(
59 (r'<div class="tv_translation">\s*<h1><a href="[^"]+">([^<]*)</a>',
60 r"'title'\s*:\s*'([^']+)'"),
61 webpage, 'title', default=None) or item['title']
62 description = self._html_search_regex(
63 r'<div class="descr">\s*<div> </div>\s*<p>([^<]*)</p></div>',
64 webpage, 'description', default=None) or self._html_search_meta(
65 'description', webpage, 'description')
66 duration = int_or_none(self._html_search_meta(
67 'video:duration', webpage, 'video duration', fatal=False))
68 upload_date = unified_strdate(self._html_search_meta(
69 'ya:ovs:upload_date', webpage, 'upload date', fatal=False))
73 'thumbnail': item.get('poster') or self._og_search_thumbnail(webpage),
75 'description': description,
76 'upload_date': upload_date,
77 'duration': int_or_none(duration),