1 from .common
import InfoExtractor
10 class LRTBaseIE(InfoExtractor
):
11 def _extract_js_var(self
, webpage
, var_name
, default
=None):
12 return self
._search
_regex
(
13 fr
'{var_name}\s*=\s*(["\'])((?
:(?
!\
1).)+)\
1',
14 webpage, var_name.replace('_
', ' '), default, group=2)
17 class LRTStreamIE(LRTBaseIE):
18 _VALID_URL = r'https?
://(?
:www\
.)?lrt\
.lt
/mediateka
/tiesiogiai
/(?P
<id>[\w
-]+)'
20 'url
': 'https
://www
.lrt
.lt
/mediateka
/tiesiogiai
/lrt
-opus
',
23 'live_status
': 'is_live
',
24 'title
': 're
:^LRT Opus
.+$
',
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
32 streams_data = self._download_json(self._extract_js_var(webpage, 'tokenURL
'), video_id)
34 formats, subtitles = [], {}
35 for stream_url in traverse_obj(streams_data, (
36 'response
', 'data
', lambda k, _: k.startswith('content
')), expected_type=url_or_none):
37 fmts, subs = self._extract_m3u8_formats_and_subtitles(stream_url, video_id, 'mp4
', m3u8_id='hls
', live=True)
39 subtitles = self._merge_subtitles(subtitles, subs)
41 stream_title = self._extract_js_var(webpage, 'video_title
', 'LRT
')
45 'subtitles
': subtitles,
47 'title
': f'{self
._og
_search
_title
(webpage
)} - {stream_title}
'
51 class LRTVODIE(LRTBaseIE):
52 _VALID_URL = r'https?
://(?
:www\
.)?lrt\
.lt(?P
<path
>/mediateka
/irasas
/(?P
<id>[0-9]+))'
55 'url
': 'https
://www
.lrt
.lt
/mediateka
/irasas
/2000127261/greita
-ir
-gardu
-sicilijos
-ikvepta
-klasikiniu
-makaronu
-su
-baklazanais
-vakariene
',
59 'title
': 'Greita ir gardu
: Sicilijos įkvėpta klasikinių makaronų su baklažanais vakarienė
',
60 'description
': 'md5
:ad7d985f51b0dc1489ba2d76d7ed47fa
',
62 'timestamp
': 1604079000,
63 'upload_date
': '20201030',
64 'tags
': ['LRT TELEVIZIJA
', 'Beatos virtuvė
', 'Beata Nicholson
', 'Makaronai
', 'Baklažanai
', 'Vakarienė
', 'Receptas
'],
65 'thumbnail
': 'https
://www
.lrt
.lt
/img
/2020/10/30/764041-126478-1287x836
.jpg
'
69 'url
': 'http
://www
.lrt
.lt
/mediateka
/irasas
/1013074524/',
70 'md5
': '389da8ca3cad0f51d12bed0c844f6a0a
',
74 'title
': 'Kita tema
2016-09-05 15:05',
75 'description
': 'md5
:1b295a8fc7219ed0d543fc228c931fb5
',
82 def _real_extract(self, url):
83 path, video_id = self._match_valid_url(url).groups()
84 webpage = self._download_webpage(url, video_id)
86 media_url = self._extract_js_var(webpage, 'main_url
', path)
87 media = self._download_json(self._extract_js_var(
88 webpage, 'media_info_url
',
89 'https
://www
.lrt
.lt
/servisai
/stream_url
/vod
/media_info
/'),
90 video_id, query={'url
': media_url})
91 jw_data = self._parse_jwplayer_data(
92 media['playlist_item
'], video_id, base_url=url)
94 json_ld_data = self._search_json_ld(webpage, video_id)
97 for tag in (media.get('tags
') or []):
98 tag_name = tag.get('name
')
101 tags.append(tag_name)
104 'description
': clean_html(media.get('content
')),
108 return merge_dicts(clean_info, jw_data, json_ld_data)