|
|
@ -5,28 +5,26 @@ import re
|
|
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
from ..utils import (
|
|
|
|
determine_ext,
|
|
|
|
clean_html,
|
|
|
|
int_or_none,
|
|
|
|
merge_dicts,
|
|
|
|
parse_duration,
|
|
|
|
|
|
|
|
remove_end,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LRTIE(InfoExtractor):
|
|
|
|
class LRTIE(InfoExtractor):
|
|
|
|
IE_NAME = 'lrt.lt'
|
|
|
|
IE_NAME = 'lrt.lt'
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?lrt\.lt/mediateka/irasas/(?P<id>[0-9]+)'
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?lrt\.lt(?P<path>/mediateka/irasas/(?P<id>[0-9]+))'
|
|
|
|
_TESTS = [{
|
|
|
|
_TESTS = [{
|
|
|
|
# m3u8 download
|
|
|
|
# m3u8 download
|
|
|
|
'url': 'http://www.lrt.lt/mediateka/irasas/54391/',
|
|
|
|
'url': 'https://www.lrt.lt/mediateka/irasas/2000127261/greita-ir-gardu-sicilijos-ikvepta-klasikiniu-makaronu-su-baklazanais-vakariene',
|
|
|
|
'md5': 'fe44cf7e4ab3198055f2c598fc175cb0',
|
|
|
|
'md5': '85cb2bb530f31d91a9c65b479516ade4',
|
|
|
|
'info_dict': {
|
|
|
|
'info_dict': {
|
|
|
|
'id': '54391',
|
|
|
|
'id': '2000127261',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Septynios Kauno dienos',
|
|
|
|
'title': 'Greita ir gardu: Sicilijos įkvėpta klasikinių makaronų su baklažanais vakarienė',
|
|
|
|
'description': 'md5:24d84534c7dc76581e59f5689462411a',
|
|
|
|
'description': 'md5:ad7d985f51b0dc1489ba2d76d7ed47fa',
|
|
|
|
'duration': 1783,
|
|
|
|
'duration': 3035,
|
|
|
|
'view_count': int,
|
|
|
|
'timestamp': 1604079000,
|
|
|
|
'like_count': int,
|
|
|
|
'upload_date': '20201030',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
# direct mp3 download
|
|
|
|
# direct mp3 download
|
|
|
@ -43,52 +41,35 @@ class LRTIE(InfoExtractor):
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _extract_js_var(self, webpage, var_name, default):
|
|
|
|
|
|
|
|
return self._search_regex(
|
|
|
|
|
|
|
|
r'%s\s*=\s*(["\'])((?:(?!\1).)+)\1' % var_name,
|
|
|
|
|
|
|
|
webpage, var_name.replace('_', ' '), default, group=2)
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
path, video_id = re.match(self._VALID_URL, url).groups()
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
|
|
|
|
title = remove_end(self._og_search_title(webpage), ' - LRT')
|
|
|
|
media_url = self._extract_js_var(webpage, 'main_url', path)
|
|
|
|
|
|
|
|
media = self._download_json(self._extract_js_var(
|
|
|
|
formats = []
|
|
|
|
webpage, 'media_info_url',
|
|
|
|
for _, file_url in re.findall(
|
|
|
|
'https://www.lrt.lt/servisai/stream_url/vod/media_info/'),
|
|
|
|
r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage):
|
|
|
|
video_id, query={'url': media_url})
|
|
|
|
ext = determine_ext(file_url)
|
|
|
|
jw_data = self._parse_jwplayer_data(
|
|
|
|
if ext not in ('m3u8', 'mp3'):
|
|
|
|
media['playlist_item'], video_id, base_url=url)
|
|
|
|
continue
|
|
|
|
|
|
|
|
# mp3 served as m3u8 produces stuttered media file
|
|
|
|
|
|
|
|
if ext == 'm3u8' and '.mp3' in file_url:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
if ext == 'm3u8':
|
|
|
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
|
|
|
|
file_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
|
|
|
|
|
|
|
fatal=False))
|
|
|
|
|
|
|
|
elif ext == 'mp3':
|
|
|
|
|
|
|
|
formats.append({
|
|
|
|
|
|
|
|
'url': file_url,
|
|
|
|
|
|
|
|
'vcodec': 'none',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thumbnail = self._og_search_thumbnail(webpage)
|
|
|
|
json_ld_data = self._search_json_ld(webpage, video_id)
|
|
|
|
description = self._og_search_description(webpage)
|
|
|
|
|
|
|
|
duration = parse_duration(self._search_regex(
|
|
|
|
|
|
|
|
r'var\s+record_len\s*=\s*(["\'])(?P<duration>[0-9]+:[0-9]+:[0-9]+)\1',
|
|
|
|
|
|
|
|
webpage, 'duration', default=None, group='duration'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view_count = int_or_none(self._html_search_regex(
|
|
|
|
tags = []
|
|
|
|
r'<div[^>]+class=(["\']).*?record-desc-seen.*?\1[^>]*>(?P<count>.+?)</div>',
|
|
|
|
for tag in media.get('tags', []):
|
|
|
|
webpage, 'view count', fatal=False, group='count'))
|
|
|
|
tag_name = tag.get('name')
|
|
|
|
like_count = int_or_none(self._search_regex(
|
|
|
|
if not tag_name:
|
|
|
|
r'<span[^>]+id=(["\'])flikesCount.*?\1>(?P<count>\d+)<',
|
|
|
|
continue
|
|
|
|
webpage, 'like count', fatal=False, group='count'))
|
|
|
|
tags.append(tag_name)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
clean_info = {
|
|
|
|
'id': video_id,
|
|
|
|
'description': clean_html(media.get('content')),
|
|
|
|
'title': title,
|
|
|
|
'tags': tags,
|
|
|
|
'formats': formats,
|
|
|
|
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
|
|
|
|
'description': description,
|
|
|
|
|
|
|
|
'duration': duration,
|
|
|
|
|
|
|
|
'view_count': view_count,
|
|
|
|
|
|
|
|
'like_count': like_count,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return merge_dicts(clean_info, jw_data, json_ld_data)
|
|
|
|