mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.0 KiB
Python
113 lines
4.0 KiB
Python
![]()
8 years ago
|
import re
|
||
|
|
||
![]()
4 years ago
|
from .common import InfoExtractor
|
||
![]()
8 years ago
|
from ..utils import (
|
||
![]()
4 years ago
|
extract_attributes,
|
||
![]()
8 years ago
|
int_or_none,
|
||
![]()
4 years ago
|
mimetype2ext,
|
||
|
parse_iso8601,
|
||
![]()
8 years ago
|
)
|
||
|
|
||
|
|
||
![]()
4 years ago
|
class MedialaanIE(InfoExtractor):
|
||
![]()
8 years ago
|
_VALID_URL = r'''(?x)
|
||
|
https?://
|
||
|
(?:
|
||
![]()
4 years ago
|
(?: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
|
||
![]()
8 years ago
|
)
|
||
![]()
4 years ago
|
(?P<id>\d+)
|
||
![]()
8 years ago
|
'''
|
||
|
_TESTS = [{
|
||
![]()
4 years ago
|
'url': 'https://www.bndestem.nl/video/de-terugkeer-van-ally-de-aap-en-wie-vertrekt-er-nog-bij-nac~p193993',
|
||
![]()
8 years ago
|
'info_dict': {
|
||
![]()
4 years ago
|
'id': '193993',
|
||
![]()
8 years ago
|
'ext': 'mp4',
|
||
![]()
4 years ago
|
'title': 'De terugkeer van Ally de Aap en wie vertrekt er nog bij NAC?',
|
||
|
'timestamp': 1611663540,
|
||
|
'upload_date': '20210126',
|
||
|
'duration': 238,
|
||
![]()
8 years ago
|
},
|
||
|
'params': {
|
||
|
'skip_download': True,
|
||
|
},
|
||
|
}, {
|
||
![]()
4 years ago
|
'url': 'https://www.gelderlander.nl/video/kanalen/degelderlander~c320/series/snel-nieuws~s984/noodbevel-in-doetinchem-politie-stuurt-mensen-centrum-uit~p194093',
|
||
![]()
8 years ago
|
'only_matching': True,
|
||
|
}, {
|
||
![]()
4 years ago
|
'url': 'https://embed.mychannels.video/sdk/production/193993?options=TFTFF_default',
|
||
![]()
8 years ago
|
'only_matching': True,
|
||
|
}, {
|
||
![]()
4 years ago
|
'url': 'https://embed.mychannels.video/script/production/193993',
|
||
![]()
8 years ago
|
'only_matching': True,
|
||
|
}, {
|
||
![]()
4 years ago
|
'url': 'https://embed.mychannels.video/production/193993',
|
||
![]()
8 years ago
|
'only_matching': True,
|
||
![]()
7 years ago
|
}, {
|
||
![]()
4 years ago
|
'url': 'https://mychannels.video/embed/193993',
|
||
|
'only_matching': True,
|
||
![]()
7 years ago
|
}, {
|
||
![]()
4 years ago
|
'url': 'https://embed.mychannels.video/embed/193993',
|
||
![]()
7 years ago
|
'only_matching': True,
|
||
![]()
8 years ago
|
}]
|
||
|
|
||
![]()
4 years ago
|
@staticmethod
|
||
|
def _extract_urls(webpage):
|
||
|
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
|
||
![]()
8 years ago
|
|
||
|
def _real_extract(self, url):
|
||
![]()
4 years ago
|
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))
|
||
![]()
8 years ago
|
else:
|
||
![]()
4 years ago
|
formats.append({
|
||
|
'ext': ext,
|
||
|
'url': src,
|
||
![]()
8 years ago
|
})
|
||
![]()
4 years ago
|
self._sort_formats(formats)
|
||
|
|
||
|
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,
|
||
|
}
|