Release 2024.12.03
[yt-dlp3.git] / yt_dlp / extractor / lnk.py
blob593f73410d10ba5983c906054739e65871406c30
1 from .common import InfoExtractor
2 from ..utils import (
3 format_field,
4 int_or_none,
5 unified_strdate,
9 class LnkIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?lnk\.lt/[^/]+/(?P<id>\d+)'
12 _TESTS = [{
13 'url': 'https://lnk.lt/zinios/79791',
14 'info_dict': {
15 'id': '79791',
16 'ext': 'mp4',
17 'title': 'LNK.lt: Viešintų gyventojai sukilo prieš radijo bangų siųstuvą',
18 'description': 'Svarbiausios naujienos trumpai, LNK žinios ir Info dienos pokalbiai.',
19 'view_count': int,
20 'duration': 233,
21 'upload_date': '20191123',
22 'thumbnail': r're:^https?://.*\.jpg$',
23 'episode_number': 13431,
24 'series': 'Naujausi žinių reportažai',
25 'episode': 'Episode 13431',
27 'params': {'skip_download': True},
28 }, {
29 'url': 'https://lnk.lt/istorijos-trumpai/152546',
30 'info_dict': {
31 'id': '152546',
32 'ext': 'mp4',
33 'title': 'Radžio koncertas gaisre ',
34 'description': 'md5:0666b5b85cb9fc7c1238dec96f71faba',
35 'view_count': int,
36 'duration': 54,
37 'upload_date': '20220105',
38 'thumbnail': r're:^https?://.*\.jpg$',
39 'episode_number': 1036,
40 'series': 'Istorijos trumpai',
41 'episode': 'Episode 1036',
43 'params': {'skip_download': True},
44 }, {
45 'url': 'https://lnk.lt/gyvunu-pasaulis/151549',
46 'info_dict': {
47 'id': '151549',
48 'ext': 'mp4',
49 'title': 'Gyvūnų pasaulis',
50 'description': '',
51 'view_count': int,
52 'duration': 1264,
53 'upload_date': '20220108',
54 'thumbnail': r're:^https?://.*\.jpg$',
55 'episode_number': 16,
56 'series': 'Gyvūnų pasaulis',
57 'episode': 'Episode 16',
59 'params': {'skip_download': True},
62 def _real_extract(self, url):
63 video_id = self._match_id(url)
64 video_json = self._download_json(f'https://lnk.lt/api/video/video-config/{video_id}', video_id)['videoInfo']
65 formats, subtitles = [], {}
66 if video_json.get('videoUrl'):
67 fmts, subs = self._extract_m3u8_formats_and_subtitles(video_json['videoUrl'], video_id)
68 formats.extend(fmts)
69 subtitles = self._merge_subtitles(subtitles, subs)
70 if video_json.get('videoFairplayUrl') and not video_json.get('drm'):
71 fmts, subs = self._extract_m3u8_formats_and_subtitles(video_json['videoFairplayUrl'], video_id)
72 formats.extend(fmts)
73 subtitles = self._merge_subtitles(subtitles, subs)
75 return {
76 'id': video_id,
77 'title': video_json.get('title'),
78 'description': video_json.get('description'),
79 'view_count': video_json.get('viewsCount'),
80 'duration': video_json.get('duration'),
81 'upload_date': unified_strdate(video_json.get('airDate')),
82 'thumbnail': format_field(video_json, 'posterImage', 'https://lnk.lt/all-images/%s'),
83 'episode_number': int_or_none(video_json.get('episodeNumber')),
84 'series': video_json.get('programTitle'),
85 'formats': formats,
86 'subtitles': subtitles,