2020-09-02 18:18:09 +02:00
|
|
|
from .common import InfoExtractor
|
2022-04-03 17:11:50 +02:00
|
|
|
from ..utils import determine_ext
|
2020-09-02 18:18:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ElonetIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://elonet\.finna\.fi/Record/kavi\.elonet_elokuva_(?P<id>[0-9]+)'
|
2021-04-18 02:09:48 +02:00
|
|
|
_TESTS = [{
|
2020-09-02 18:18:09 +02:00
|
|
|
'url': 'https://elonet.finna.fi/Record/kavi.elonet_elokuva_107867',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '107867',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Valkoinen peura',
|
2022-04-03 17:11:50 +02:00
|
|
|
'thumbnail': r're:^https?://elonet\.finna\.fi/Cover/Show\?id=kavi\.elonet_elokuva_107867.+',
|
|
|
|
'description': 'md5:bded4201c9677fab10854884fe8f7312',
|
2020-09-02 18:18:09 +02:00
|
|
|
},
|
2022-04-03 17:11:50 +02:00
|
|
|
'params': {'skip_download': 'dash'},
|
2021-04-18 02:09:48 +02:00
|
|
|
}, {
|
|
|
|
# DASH with subtitles
|
|
|
|
'url': 'https://elonet.finna.fi/Record/kavi.elonet_elokuva_116539',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '116539',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Minulla on tiikeri',
|
2022-04-03 17:11:50 +02:00
|
|
|
'thumbnail': r're:^https?://elonet\.finna\.fi/Cover/Show\?id=kavi\.elonet_elokuva_116539.+',
|
|
|
|
'description': 'md5:5ab72b3fe76d3414e46cc8f277104419',
|
|
|
|
},
|
|
|
|
'params': {'skip_download': 'dash'},
|
|
|
|
}, {
|
|
|
|
# Page with multiple videos, download the main one
|
|
|
|
'url': 'https://elonet.finna.fi/Record/kavi.elonet_elokuva_117396',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '117396',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Sampo',
|
|
|
|
'thumbnail': r're:^https?://elonet\.finna\.fi/Cover/Show\?id=kavi\.elonet_elokuva_117396.+',
|
|
|
|
'description': 'md5:ec69572a5b054d0ecafe8086b1fa96f7',
|
|
|
|
},
|
|
|
|
'params': {'skip_download': 'dash'},
|
2021-04-18 02:09:48 +02:00
|
|
|
}]
|
2020-09-02 18:18:09 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2022-04-03 17:11:50 +02:00
|
|
|
src = self._parse_json(self._html_search_regex(
|
|
|
|
r'id=\'video-data\'[^>]+data-video-sources="([^"]+)"', webpage, 'json'), video_id)[0]['src']
|
|
|
|
ext = determine_ext(src)
|
2020-09-02 18:18:09 +02:00
|
|
|
|
2022-04-03 17:11:50 +02:00
|
|
|
if ext == 'm3u8':
|
|
|
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(src, video_id, fatal=False)
|
|
|
|
elif ext == 'mpd':
|
|
|
|
formats, subtitles = self._extract_mpd_formats_and_subtitles(src, video_id, fatal=False)
|
2020-09-02 18:18:09 +02:00
|
|
|
else:
|
2022-04-03 17:11:50 +02:00
|
|
|
formats, subtitles = [], {}
|
|
|
|
self.raise_no_formats(f'Unknown streaming format {ext}')
|
|
|
|
self._sort_formats(formats)
|
2020-09-02 18:18:09 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2022-04-03 17:11:50 +02:00
|
|
|
'title': self._og_search_title(webpage),
|
|
|
|
'description': self._og_search_description(webpage),
|
|
|
|
'thumbnail': self._og_search_thumbnail(webpage),
|
2020-09-02 18:18:09 +02:00
|
|
|
'formats': formats,
|
2021-04-18 02:09:48 +02:00
|
|
|
'subtitles': subtitles,
|
2020-09-02 18:18:09 +02:00
|
|
|
}
|