2017-03-17 23:58:54 +01:00
|
|
|
import re
|
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
from .common import InfoExtractor
|
2017-03-17 23:58:54 +01:00
|
|
|
from ..utils import (
|
2021-02-04 08:56:01 +01:00
|
|
|
extract_attributes,
|
2017-03-17 23:58:54 +01:00
|
|
|
int_or_none,
|
2021-02-04 08:56:01 +01:00
|
|
|
mimetype2ext,
|
|
|
|
parse_iso8601,
|
2017-03-17 23:58:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
class MedialaanIE(InfoExtractor):
|
2017-03-17 23:58:54 +01:00
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
https?://
|
|
|
|
(?:
|
2021-02-04 08:56:01 +01:00
|
|
|
(?:embed\.)?mychannels.video/embed/|
|
|
|
|
embed\.mychannels\.video/(?:s(?:dk|cript)/)?production/|
|
|
|
|
(?:www\.)?(?:
|
|
|
|
(?:
|
|
|
|
7sur7|
|
|
|
|
demorgen|
|
|
|
|
hln|
|
|
|
|
joe|
|
|
|
|
qmusic
|
|
|
|
)\.be|
|
|
|
|
(?:
|
|
|
|
[abe]d|
|
|
|
|
bndestem|
|
|
|
|
destentor|
|
|
|
|
gelderlander|
|
|
|
|
pzc|
|
|
|
|
tubantia|
|
|
|
|
volkskrant
|
|
|
|
)\.nl
|
|
|
|
)/video/(?:[^/]+/)*[^/?&#]+~p
|
2017-03-17 23:58:54 +01:00
|
|
|
)
|
2021-02-04 08:56:01 +01:00
|
|
|
(?P<id>\d+)
|
2017-03-17 23:58:54 +01:00
|
|
|
'''
|
|
|
|
_TESTS = [{
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://www.bndestem.nl/video/de-terugkeer-van-ally-de-aap-en-wie-vertrekt-er-nog-bij-nac~p193993',
|
2017-03-17 23:58:54 +01:00
|
|
|
'info_dict': {
|
2021-02-04 08:56:01 +01:00
|
|
|
'id': '193993',
|
2017-03-17 23:58:54 +01:00
|
|
|
'ext': 'mp4',
|
2021-02-04 08:56:01 +01:00
|
|
|
'title': 'De terugkeer van Ally de Aap en wie vertrekt er nog bij NAC?',
|
|
|
|
'timestamp': 1611663540,
|
|
|
|
'upload_date': '20210126',
|
|
|
|
'duration': 238,
|
2017-03-17 23:58:54 +01:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}, {
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://www.gelderlander.nl/video/kanalen/degelderlander~c320/series/snel-nieuws~s984/noodbevel-in-doetinchem-politie-stuurt-mensen-centrum-uit~p194093',
|
2017-03-17 23:58:54 +01:00
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://embed.mychannels.video/sdk/production/193993?options=TFTFF_default',
|
2017-03-17 23:58:54 +01:00
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://embed.mychannels.video/script/production/193993',
|
2017-03-17 23:58:54 +01:00
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://embed.mychannels.video/production/193993',
|
2017-03-17 23:58:54 +01:00
|
|
|
'only_matching': True,
|
2017-04-18 05:44:33 +02:00
|
|
|
}, {
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://mychannels.video/embed/193993',
|
|
|
|
'only_matching': True,
|
2017-04-18 05:44:33 +02:00
|
|
|
}, {
|
2021-02-04 08:56:01 +01:00
|
|
|
'url': 'https://embed.mychannels.video/embed/193993',
|
2017-04-18 05:44:33 +02:00
|
|
|
'only_matching': True,
|
2017-03-17 23:58:54 +01:00
|
|
|
}]
|
|
|
|
|
2022-08-01 03:23:25 +02:00
|
|
|
@classmethod
|
|
|
|
def _extract_embed_urls(cls, url, webpage):
|
2021-02-04 08:56:01 +01:00
|
|
|
entries = []
|
|
|
|
for element in re.findall(r'(<div[^>]+data-mychannels-type="video"[^>]*>)', webpage):
|
|
|
|
mychannels_id = extract_attributes(element).get('data-mychannels-id')
|
|
|
|
if mychannels_id:
|
|
|
|
entries.append('https://mychannels.video/embed/' + mychannels_id)
|
|
|
|
return entries
|
2017-03-17 23:58:54 +01:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-02-04 08:56:01 +01:00
|
|
|
production_id = self._match_id(url)
|
|
|
|
production = self._download_json(
|
|
|
|
'https://embed.mychannels.video/sdk/production/' + production_id,
|
|
|
|
production_id, query={'options': 'UUUU_default'})['productions'][0]
|
|
|
|
title = production['title']
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
for source in (production.get('sources') or []):
|
|
|
|
src = source.get('src')
|
|
|
|
if not src:
|
|
|
|
continue
|
|
|
|
ext = mimetype2ext(source.get('type'))
|
|
|
|
if ext == 'm3u8':
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
src, production_id, 'mp4', 'm3u8_native',
|
|
|
|
m3u8_id='hls', fatal=False))
|
2017-03-17 23:58:54 +01:00
|
|
|
else:
|
2021-02-04 08:56:01 +01:00
|
|
|
formats.append({
|
|
|
|
'ext': ext,
|
|
|
|
'url': src,
|
2017-03-17 23:58:54 +01:00
|
|
|
})
|
2021-02-04 08:56:01 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': production_id,
|
|
|
|
'title': title,
|
|
|
|
'formats': formats,
|
|
|
|
'thumbnail': production.get('posterUrl'),
|
|
|
|
'timestamp': parse_iso8601(production.get('publicationDate'), ' '),
|
|
|
|
'duration': int_or_none(production.get('duration')) or None,
|
|
|
|
}
|