2015-01-13 17:14:59 -05:00
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..utils import (
|
2019-11-06 17:14:26 -05:00
|
|
|
|
clean_html,
|
2022-01-21 01:02:31 -05:00
|
|
|
|
format_field,
|
2015-01-13 17:14:59 -05:00
|
|
|
|
int_or_none,
|
2019-11-06 17:14:26 -05:00
|
|
|
|
parse_iso8601,
|
2022-01-21 01:02:31 -05:00
|
|
|
|
unified_strdate,
|
2015-01-13 17:14:59 -05:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LnkGoIE(InfoExtractor):
|
2019-11-06 17:14:26 -05:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?lnk(?:go)?\.(?:alfa\.)?lt/(?:visi-video/[^/]+|video)/(?P<id>[A-Za-z0-9-]+)(?:/(?P<episode_id>\d+))?'
|
2015-01-13 17:14:59 -05:00
|
|
|
|
_TESTS = [{
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'url': 'http://www.lnkgo.lt/visi-video/aktualai-pratesimas/ziurek-putka-trys-klausimai',
|
2015-01-13 17:14:59 -05:00
|
|
|
|
'info_dict': {
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'id': '10809',
|
2015-01-13 17:14:59 -05:00
|
|
|
|
'ext': 'mp4',
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'title': "Put'ka: Trys Klausimai",
|
|
|
|
|
'upload_date': '20161216',
|
|
|
|
|
'description': 'Seniai matytas Put’ka užduoda tris klausimėlius. Pabandykime surasti atsakymus.',
|
|
|
|
|
'age_limit': 18,
|
|
|
|
|
'duration': 117,
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'timestamp': 1481904000,
|
2015-01-13 17:14:59 -05:00
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True, # HLS download
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://lnkgo.alfa.lt/visi-video/aktualai-pratesimas/ziurek-nerdas-taiso-kompiuteri-2',
|
|
|
|
|
'info_dict': {
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'id': '10467',
|
2015-01-13 17:14:59 -05:00
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Nėrdas: Kompiuterio Valymas',
|
|
|
|
|
'upload_date': '20150113',
|
|
|
|
|
'description': 'md5:7352d113a242a808676ff17e69db6a69',
|
|
|
|
|
'age_limit': 18,
|
|
|
|
|
'duration': 346,
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'timestamp': 1421164800,
|
2015-01-13 17:14:59 -05:00
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True, # HLS download
|
|
|
|
|
},
|
2017-10-06 12:59:09 -04:00
|
|
|
|
}, {
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'url': 'https://lnk.lt/video/neigalieji-tv-bokste/37413',
|
2017-10-06 12:59:09 -04:00
|
|
|
|
'only_matching': True,
|
2015-01-13 17:14:59 -05:00
|
|
|
|
}]
|
|
|
|
|
_AGE_LIMITS = {
|
|
|
|
|
'N-7': 7,
|
|
|
|
|
'N-14': 14,
|
|
|
|
|
'S': 18,
|
|
|
|
|
}
|
2019-11-06 17:14:26 -05:00
|
|
|
|
_M3U8_TEMPL = 'https://vod.lnk.lt/lnk_vod/lnk/lnk/%s:%s/playlist.m3u8%s'
|
2015-01-13 17:14:59 -05:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-18 21:41:24 -04:00
|
|
|
|
display_id, video_id = self._match_valid_url(url).groups()
|
2015-01-13 17:14:59 -05:00
|
|
|
|
|
2019-11-06 17:14:26 -05:00
|
|
|
|
video_info = self._download_json(
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'https://lnk.lt/api/main/video-page/{}/{}/false'.format(display_id, video_id or '0'),
|
2019-11-06 17:14:26 -05:00
|
|
|
|
display_id)['videoConfig']['videoInfo']
|
2015-01-13 17:14:59 -05:00
|
|
|
|
|
2024-06-11 19:09:58 -04:00
|
|
|
|
video_id = str(video_info['id'])
|
2019-11-06 17:14:26 -05:00
|
|
|
|
title = video_info['title']
|
|
|
|
|
prefix = 'smil' if video_info.get('isQualityChangeAvailable') else 'mp4'
|
|
|
|
|
formats = self._extract_m3u8_formats(
|
|
|
|
|
self._M3U8_TEMPL % (prefix, video_info['videoUrl'], video_info.get('secureTokenParams') or ''),
|
|
|
|
|
video_id, 'mp4', 'm3u8_native')
|
2015-01-13 17:14:59 -05:00
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'id': video_id,
|
|
|
|
|
'display_id': display_id,
|
|
|
|
|
'title': title,
|
|
|
|
|
'formats': formats,
|
2022-01-21 02:57:40 -05:00
|
|
|
|
'thumbnail': format_field(video_info, 'posterImage', 'https://lnk.lt/all-images/%s'),
|
2019-11-06 17:14:26 -05:00
|
|
|
|
'duration': int_or_none(video_info.get('duration')),
|
|
|
|
|
'description': clean_html(video_info.get('htmlDescription')),
|
|
|
|
|
'age_limit': self._AGE_LIMITS.get(video_info.get('pgRating'), 0),
|
|
|
|
|
'timestamp': parse_iso8601(video_info.get('airDate')),
|
|
|
|
|
'view_count': int_or_none(video_info.get('viewsCount')),
|
2015-01-13 17:14:59 -05:00
|
|
|
|
}
|
2022-01-21 01:02:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LnkIE(InfoExtractor):
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?lnk\.lt/[^/]+/(?P<id>\d+)'
|
|
|
|
|
|
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://lnk.lt/zinios/79791',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '79791',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'LNK.lt: Viešintų gyventojai sukilo prieš radijo bangų siųstuvą',
|
|
|
|
|
'description': 'Svarbiausios naujienos trumpai, LNK žinios ir Info dienos pokalbiai.',
|
|
|
|
|
'view_count': int,
|
|
|
|
|
'duration': 233,
|
|
|
|
|
'upload_date': '20191123',
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'episode_number': 13431,
|
|
|
|
|
'series': 'Naujausi žinių reportažai',
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'episode': 'Episode 13431',
|
2022-01-21 01:02:31 -05:00
|
|
|
|
},
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'params': {'skip_download': True},
|
2022-01-21 01:02:31 -05:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://lnk.lt/istorijos-trumpai/152546',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '152546',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Radžio koncertas gaisre ',
|
|
|
|
|
'description': 'md5:0666b5b85cb9fc7c1238dec96f71faba',
|
|
|
|
|
'view_count': int,
|
|
|
|
|
'duration': 54,
|
|
|
|
|
'upload_date': '20220105',
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'episode_number': 1036,
|
|
|
|
|
'series': 'Istorijos trumpai',
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'episode': 'Episode 1036',
|
2022-01-21 01:02:31 -05:00
|
|
|
|
},
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'params': {'skip_download': True},
|
2022-01-21 01:02:31 -05:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://lnk.lt/gyvunu-pasaulis/151549',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '151549',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Gyvūnų pasaulis',
|
|
|
|
|
'description': '',
|
|
|
|
|
'view_count': int,
|
|
|
|
|
'duration': 1264,
|
|
|
|
|
'upload_date': '20220108',
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'episode_number': 16,
|
|
|
|
|
'series': 'Gyvūnų pasaulis',
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'episode': 'Episode 16',
|
2022-01-21 01:02:31 -05:00
|
|
|
|
},
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'params': {'skip_download': True},
|
2022-01-21 01:02:31 -05:00
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2024-06-11 19:09:58 -04:00
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
video_json = self._download_json(f'https://lnk.lt/api/video/video-config/{video_id}', video_id)['videoInfo']
|
2022-01-21 01:02:31 -05:00
|
|
|
|
formats, subtitles = [], {}
|
|
|
|
|
if video_json.get('videoUrl'):
|
2024-06-11 19:09:58 -04:00
|
|
|
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(video_json['videoUrl'], video_id)
|
2022-01-21 01:02:31 -05:00
|
|
|
|
formats.extend(fmts)
|
|
|
|
|
subtitles = self._merge_subtitles(subtitles, subs)
|
|
|
|
|
if video_json.get('videoFairplayUrl') and not video_json.get('drm'):
|
2024-06-11 19:09:58 -04:00
|
|
|
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(video_json['videoFairplayUrl'], video_id)
|
2022-01-21 01:02:31 -05:00
|
|
|
|
formats.extend(fmts)
|
|
|
|
|
subtitles = self._merge_subtitles(subtitles, subs)
|
|
|
|
|
|
|
|
|
|
return {
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'id': video_id,
|
2022-01-21 01:02:31 -05:00
|
|
|
|
'title': video_json.get('title'),
|
|
|
|
|
'description': video_json.get('description'),
|
|
|
|
|
'view_count': video_json.get('viewsCount'),
|
|
|
|
|
'duration': video_json.get('duration'),
|
|
|
|
|
'upload_date': unified_strdate(video_json.get('airDate')),
|
|
|
|
|
'thumbnail': format_field(video_json, 'posterImage', 'https://lnk.lt/all-images/%s'),
|
|
|
|
|
'episode_number': int_or_none(video_json.get('episodeNumber')),
|
|
|
|
|
'series': video_json.get('programTitle'),
|
|
|
|
|
'formats': formats,
|
|
|
|
|
'subtitles': subtitles,
|
|
|
|
|
}
|