4 from .common
import InfoExtractor
16 from ..utils
.traversal
import traverse_obj
19 class LSMLREmbedIE(InfoExtractor
):
22 (?:latvijasradio|lr1|lr2|klasika|lr4|naba|radioteatris)\.lsm|
26 )/?\?(?:[^#]+&)?(?:show|id)=(?P<id>\d+)'''
28 'url': 'https://latvijasradio.lsm.lv/lv/embed/?theme=black&size=16x9&showCaptions=0&id=183522',
29 'md5': '719b33875cd1429846eeeaeec6df2830',
34 'title': '#138 Nepilnīgā kompensējamo zāļu sistēma pat mēnešiem dzenā pacientus pa aptiekām',
35 'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/9/d/gallery_fd4675ac.jpg',
38 'url': 'https://radioteatris.lsm.lv/lv/embed/?id=&show=1270&theme=white&size=16x9',
44 'md5': '2e61b6eceff00d14d57fdbbe6ab24cac',
48 'title': 'Eriks Emanuels Šmits "Pilāta evaņģēlijs". 1. daļa',
49 'thumbnail': 'https://radioteatris.lsm.lv/public/assets/shows/62f131ae81e3c.jpg',
54 'url': 'https://radioteatris.lsm.lv/lv/embed/?id=&show=1269&theme=white&size=16x9',
55 'md5': '24810d4a961da2295d9860afdcaf4f5a',
59 'title': 'Jens Ahlboms "Spārni". Radioizrāde ar Mārtiņa Freimaņa mūziku',
60 'thumbnail': 'https://radioteatris.lsm.lv/public/assets/shows/62f13023a457c.jpg',
64 'url': 'https://lr1.lsm.lv/lv/embed/?id=166557&show=0&theme=white&size=16x9',
70 'md5': '6a8b0927572f443f09c6e50a3ad65f2d',
74 'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/c/5/gallery_a83ad2c2.jpg',
75 'title': 'Krustpunktā Lielā intervija: Valsts prezidents Egils Levits',
79 'md5': '5d5e191e718b7644e5118b7b4e093a6d',
83 'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/c/5/gallery_a83ad2c2.jpg',
84 'title': 'Krustpunktā Lielā intervija: Valsts prezidents Egils Levits - Video Version',
89 'url': 'https://lr1.lsm.lv/lv/embed/?id=183522&show=0&theme=white&size=16x9',
90 'only_matching': True,
92 'url': 'https://lr2.lsm.lv/lv/embed/?id=182126&show=0&theme=white&size=16x9',
93 'only_matching': True,
95 'url': 'https://klasika.lsm.lv/lv/embed/?id=110806&show=0&theme=white&size=16x9',
96 'only_matching': True,
98 'url': 'https://lr4.lsm.lv/lv/embed/?id=184282&show=0&theme=white&size=16x9',
99 'only_matching': True,
101 'url': 'https://pieci.lv/lv/embed/?id=168896&show=0&theme=white&size=16x9',
102 'only_matching': True,
104 'url': 'https://naba.lsm.lv/lv/embed/?id=182901&show=0&theme=white&size=16x9',
105 'only_matching': True,
107 'url': 'https://radioteatris.lsm.lv/lv/embed/?id=176439&show=0&theme=white&size=16x9',
108 'only_matching': True,
110 'url': 'https://lr1.lsm.lv/lv/pleijeris/?embed=0&id=48205&time=00%3A00&idx=0',
111 'only_matching': True,
114 def _real_extract(self
, url
):
115 query
= parse_qs(url
)
116 video_id
= traverse_obj(query
, (
117 ('show', 'id'), 0, {int_or_none}
, filter, {str_or_none}
), get_all
=False)
118 webpage
= self
._download
_webpage
(url
, video_id
)
120 player_data
, media_data
= self
._search
_regex
(
121 r
'LR\.audio\.Player\s*\([^{]*(?P<player>\{.*?\}),(?P<media>\{.*\})\);',
122 webpage
, 'player json', group
=('player', 'media'))
124 player_json
= self
._parse
_json
(
125 player_data
, video_id
, transform_source
=js_to_json
, fatal
=False) or {}
126 media_json
= self
._parse
_json
(media_data
, video_id
, transform_source
=js_to_json
)
129 for item
in traverse_obj(media_json
, (('audio', 'video'), lambda _
, v
: v
['id'])):
131 for source_url
in traverse_obj(item
, ('sources', ..., 'file', {url_or_none}
)):
132 if determine_ext(source_url
) == 'm3u8':
133 formats
.extend(self
._extract
_m
3u8_formats
(source_url
, video_id
, fatal
=False))
135 formats
.append({'url': source_url
})
138 title
= item
.get('title')
139 if id_
.startswith('v') and not title
:
140 title
= traverse_obj(
141 media_json
, ('audio', lambda _
, v
: v
['id'][1:] == id_
[1:], 'title',
142 {lambda x
: x
and f
'{x} - Video Version'}), get_all
=False)
146 'thumbnail': urljoin(url
, player_json
.get('poster')),
149 'duration': traverse_obj(item
, ('duration', {int_or_none}
)),
152 if len(entries
) == 1:
155 return self
.playlist_result(entries
, video_id
)
158 class LSMLTVEmbedIE(InfoExtractor
):
159 _VALID_URL
= r
'https?://ltv\.lsm\.lv/embed\?(?:[^#]+&)?c=(?P<id>[^#&]+)'
161 'url': 'https://ltv.lsm.lv/embed?c=eyJpdiI6IjQzbHVUeHAyaDJiamFjcjdSUUFKdnc9PSIsInZhbHVlIjoiMHl3SnJNRmd2TmFIdnZwOGtGUUpzODFzUEZ4SVVsN2xoRjliSW9vckUyMWZIWG8vbWVzaFFkY0lhNmRjbjRpaCIsIm1hYyI6ImMzNjdhMzFhNTFhZmY1ZmE0NWI5YmFjZGI1YmJiNGEyNjgzNDM4MjUzMWEwM2FmMDMyZDMwYWM1MDFjZmM5MGIiLCJ0YWciOiIifQ==',
162 'md5': '64f72a360ca530d5ed89c77646c9eee5',
164 'id': '46k_d23-6000-105',
166 'timestamp': 1700589151,
168 'upload_date': '20231121',
169 'title': 'D23-6000-105_cetstud',
170 'thumbnail': 'https://store.cloudycdn.services/tmsp00060/assets/media/660858/placeholder1700589200.jpg',
173 'url': 'https://ltv.lsm.lv/embed?enablesdkjs=1&c=eyJpdiI6IncwVzZmUFk2MU12enVWK1I3SUcwQ1E9PSIsInZhbHVlIjoid3FhV29vamc3T2sxL1RaRmJ5Rm1GTXozU0o2dVczdUtLK0cwZEZJMDQ2a3ZIRG5DK2pneGlnbktBQy9uazVleHN6VXhxdWIweWNvcHRDSnlISlNYOHlVZ1lpcTUrcWZSTUZPQW14TVdkMW9aOUtRWVNDcFF4eWpHNGcrT0VZbUNFQStKQk91cGpndW9FVjJIa0lpbkh3PT0iLCJtYWMiOiIyZGI1NDJlMWRlM2QyMGNhOGEwYTM2MmNlN2JlOGRhY2QyYjdkMmEzN2RlOTEzYTVkNzI1ODlhZDlhZjU4MjQ2IiwidGFnIjoiIn0=',
174 'md5': 'a1711e190fe680fdb68fd8413b378e87',
178 'uploader': 'LTV_16plus',
179 'release_date': '20220514',
180 'channel_url': 'https://www.youtube.com/channel/UCNMrnafwXD2XKeeQOyfkFCw',
182 'availability': 'public',
183 'thumbnail': 'https://i.ytimg.com/vi/wUnFArIPDSY/maxresdefault.jpg',
184 'release_timestamp': 1652544074,
185 'title': 'EIROVĪZIJA SALĀTOS',
186 'live_status': 'was_live',
187 'uploader_id': '@LTV16plus',
188 'comment_count': int,
189 'channel_id': 'UCNMrnafwXD2XKeeQOyfkFCw',
190 'channel_follower_count': int,
191 'categories': ['Entertainment'],
193 'upload_date': '20220514',
195 'channel': 'LTV_16plus',
196 'playable_in_embed': True,
198 'uploader_url': 'https://www.youtube.com/@LTV16plus',
200 'description': 'md5:7ff0c42ba971e3c13e4b8a2ff03b70b5',
204 def _real_extract(self
, url
):
205 video_id
= urllib
.parse
.unquote(self
._match
_id
(url
))
206 webpage
= self
._download
_webpage
(url
, video_id
)
207 data
= self
._search
_json
(
208 r
'window\.ltvEmbedPayload\s*=', webpage
, 'embed json', video_id
)
209 embed_type
= traverse_obj(data
, ('source', 'name', {str}
))
211 if embed_type
== 'telia':
213 embed_url
= traverse_obj(data
, ('source', 'embed_url', {url_or_none}
))
214 elif embed_type
== 'youtube':
216 embed_url
= traverse_obj(data
, ('source', 'id', {str}
))
218 raise ExtractorError(f
'Unsupported embed type {embed_type!r}')
220 return self
.url_result(
221 embed_url
, ie_key
, video_id
, **traverse_obj(data
, {
222 'title': ('parentInfo', 'title'),
223 'duration': ('parentInfo', 'duration', {int_or_none}
),
224 'thumbnail': ('source', 'poster', {url_or_none}
),
228 class LSMReplayIE(InfoExtractor
):
229 _VALID_URL
= r
'https?://replay\.lsm\.lv/[^/?#]+/(?:ieraksts|statja)/[^/?#]+/(?P<id>\d+)'
231 'url': 'https://replay.lsm.lv/lv/ieraksts/ltv/311130/4-studija-zolitudes-tragedija-un-incupes-stacija',
232 'md5': '64f72a360ca530d5ed89c77646c9eee5',
234 'id': '46k_d23-6000-105',
236 'timestamp': 1700586300,
237 'description': 'md5:0f1b14798cc39e1ae578bd0eb268f759',
239 'upload_date': '20231121',
240 'title': '4. studija. Zolitūdes traģēdija un Inčupes stacija',
241 'thumbnail': 'https://ltv.lsm.lv/storage/media/8/7/large/5/1f9604e1.jpg',
244 'url': 'https://replay.lsm.lv/lv/ieraksts/lr/183522/138-nepilniga-kompensejamo-zalu-sistema-pat-menesiem-dzena-pacientus-pa-aptiekam',
245 'md5': '719b33875cd1429846eeeaeec6df2830',
250 'title': '#138 Nepilnīgā kompensējamo zāļu sistēma pat mēnešiem dzenā pacientus pa aptiekām',
251 'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/9/d/large_fd4675ac.jpg',
252 'upload_date': '20231102',
253 'timestamp': 1698921060,
254 'description': 'md5:7bac3b2dd41e44325032943251c357b1',
257 'url': 'https://replay.lsm.lv/ru/statja/ltv/311130/4-studija-zolitudes-tragedija-un-incupes-stacija',
258 'only_matching': True,
261 def _fix_nuxt_data(self
, webpage
):
262 return re
.sub(r
'Object\.create\(null(?:,(\{.+\}))?\)', lambda m
: m
.group(1) or 'null', webpage
)
264 def _real_extract(self
, url
):
265 video_id
= self
._match
_id
(url
)
266 webpage
= self
._download
_webpage
(url
, video_id
)
268 data
= self
._search
_nuxt
_data
(
269 self
._fix
_nuxt
_data
(webpage
), video_id
, context_name
='__REPLAY__')
272 '_type': 'url_transparent',
274 **traverse_obj(data
, {
275 'url': ('playback', 'service', 'url', {url_or_none}
),
276 'title': ('mediaItem', 'title'),
277 'description': ('mediaItem', ('lead', 'body')),
278 'duration': ('mediaItem', 'duration', {int_or_none}
),
279 'timestamp': ('mediaItem', 'aired_at', {parse_iso8601}
),
280 'thumbnail': ('mediaItem', 'largeThumbnail', {url_or_none}
),