3 from .common
import InfoExtractor
12 class FirstTVIE(InfoExtractor
):
14 IE_DESC
= 'Первый канал'
15 _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 'thumbnail': r
're:^https?://.*\.(?:jpg|JPG)$',
26 'upload_date': '20150212',
31 'url': 'http://www.1tv.ru/shows/dobroe-utro/pro-zdorove/vesennyaya-allergiya-dobroe-utro-fragment-vypuska-ot-07042016',
35 'title': 'Весенняя аллергия. Доброе утро. Фрагмент выпуска от 07.04.2016',
36 'thumbnail': r
're:^https?://.*\.(?:jpg|JPG)$',
37 'upload_date': '20160407',
39 'formats': 'mincount:3',
42 'skip_download': True,
45 'url': 'http://www.1tv.ru/news/issue/2016-12-01/14:00',
48 'title': 'Выпуск новостей в 14:00 1 декабря 2016 года. Новости. Первый канал',
49 'description': 'md5:2e921b948f8c1ff93901da78ebdb1dfd',
53 'url': 'http://www.1tv.ru/shows/tochvtoch-supersezon/vystupleniya/evgeniy-dyatlov-vladimir-vysockiy-koni-priveredlivye-toch-v-toch-supersezon-fragment-vypuska-ot-06-11-2016',
54 'only_matching': True,
57 def _real_extract(self
, url
):
58 display_id
= self
._match
_id
(url
)
60 webpage
= self
._download
_webpage
(url
, display_id
)
61 playlist_url
= urllib
.parse
.urljoin(url
, self
._search
_regex
(
62 r
'data-playlist-url=(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1',
63 webpage, 'playlist url
', group='url
'))
65 parsed_url = urllib.parse.urlparse(playlist_url)
66 qs = urllib.parse.parse_qs(parsed_url.query)
67 item_ids = qs.get('videos_ids
[]') or qs.get('news_ids
[]')
69 items = self._download_json(playlist_url, display_id)
73 item for item in items
74 if item.get('uid
') and str(item['uid
']) in item_ids]
79 QUALITIES = ('ld
', 'sd
', 'hd
')
83 quality = qualities(QUALITIES)
86 for f in item.get('mbr
', []):
87 src = url_or_none(f.get('src
'))
90 tbr = int_or_none(self._search_regex(
91 r'_(\d
{3,})\
.mp4
', src, 'tbr
', default=None))
93 path = self._search_regex(
94 r'//[^
/]+/(.+?
)_\d
+\
.mp4
', src,
95 'm3u8 path
', default=None)
98 'format_id
': f.get('name
'),
100 'source_preference
': quality(f.get('name
')),
101 # quality metadata of http formats may be incorrect
104 # m3u8 URL format is reverse engineered from [1] (search for
105 # master.m3u8). dashEdges (that is currently balancer-vod.1tv.ru)
107 # 1. http://static.1tv.ru/player/eump1tv-current/eump-1tv.all.min.js?rnd=9097422834:formatted
108 # 2. http://static.1tv.ru/player/eump1tv-config/config-main.js?rnd=9097422834
109 if not path and len(formats) == 1:
110 path = self._search_regex(
111 r'//[^
/]+/(.+?$
)', formats[0]['url
'],
112 'm3u8 path
', default=None)
114 if len(formats) == 1:
117 tbrs = [str(t) for t in sorted(f['tbr
'] for f in formats)]
118 m3u8_path = '_
,{},{}'.format(','.join(tbrs), '.mp4
')
119 formats.extend(self._extract_m3u8_formats(
120 f'http
://balancer
-vod
.1tv
.ru
/{path}{m3u8_path}
.urlset
/master
.m3u8
',
122 entry_protocol='m3u8_native
', m3u8_id='hls
', fatal=False))
124 thumbnail = item.get('poster
') or self._og_search_thumbnail(webpage)
125 duration = int_or_none(item.get('duration
') or self._html_search_meta(
126 'video
:duration
', webpage, 'video duration
', fatal=False))
127 upload_date = unified_strdate(self._html_search_meta(
128 'ya
:ovs
:upload_date
', webpage, 'upload date
', default=None))
131 'id': str(item.get('id') or item['uid
']),
132 'thumbnail
': thumbnail,
134 'upload_date
': upload_date,
135 'duration
': int_or_none(duration),
139 title = self._html_search_regex(
140 (r'<div
class="tv_translation">\s
*<h1
><a href
="[^"]+">([^<]*)</a>',
141 r"'title'\s
*:\s
*'([^']+)'"),
142 webpage, 'title
', default=None) or self._og_search_title(
143 webpage, default=None)
144 description = self._html_search_regex(
145 r'<div
class="descr">\s
*<div
> 
;</div
>\s
*<p
>([^
<]*)</p
></div
>',
146 webpage, 'description
', default=None) or self._html_search_meta(
147 'description
', webpage, 'description
', default=None)
149 return self.playlist_result(entries, display_id, title, description)