mirror of https://github.com/yt-dlp/yt-dlp
[ie/medialaan, vtm] Rework Extractors
parent
b7de89c910
commit
4c0a55ac8e
@ -1,60 +1,42 @@
|
|||||||
from .common import InfoExtractor
|
from .medialaan import MedialaanBaseIE
|
||||||
from ..utils import (
|
from ..utils import str_or_none
|
||||||
int_or_none,
|
from ..utils.traversal import require, traverse_obj
|
||||||
parse_iso8601,
|
|
||||||
try_get,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class VTMIE(InfoExtractor):
|
class VTMIE(MedialaanBaseIE):
|
||||||
_WORKING = False
|
_VALID_URL = r'https?://(?:www\.)?vtm\.be/[^/?#]+~v(?P<id>[\da-f-]+)'
|
||||||
_VALID_URL = r'https?://(?:www\.)?vtm\.be/([^/?&#]+)~v(?P<id>[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})'
|
_TESTS = [{
|
||||||
_TEST = {
|
|
||||||
'url': 'https://vtm.be/gast-vernielt-genkse-hotelkamer~ve7534523-279f-4b4d-a5c9-a33ffdbe23e1',
|
'url': 'https://vtm.be/gast-vernielt-genkse-hotelkamer~ve7534523-279f-4b4d-a5c9-a33ffdbe23e1',
|
||||||
'md5': '37dca85fbc3a33f2de28ceb834b071f8',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '192445',
|
'id': '192445',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Gast vernielt Genkse hotelkamer',
|
'title': 'Gast vernielt Genkse hotelkamer',
|
||||||
'timestamp': 1611060180,
|
'channel': 'VTM',
|
||||||
'upload_date': '20210119',
|
'channel_id': '867',
|
||||||
|
'description': 'md5:75fce957d219646ff1b65ba449ab97b5',
|
||||||
'duration': 74,
|
'duration': 74,
|
||||||
# TODO: fix url _type result processing
|
'genres': ['Documentaries'],
|
||||||
# 'series': 'Op Interventie',
|
'release_date': '20210119',
|
||||||
|
'release_timestamp': 1611060180,
|
||||||
|
'series': 'Op Interventie',
|
||||||
|
'series_id': '2658',
|
||||||
|
'tags': 'count:2',
|
||||||
|
'thumbnail': r're:https?://images\.mychannels\.video/imgix/.+\.(?:jpe?g|png)',
|
||||||
|
'uploader': 'VTM',
|
||||||
|
'uploader_id': '74',
|
||||||
},
|
},
|
||||||
}
|
}]
|
||||||
|
|
||||||
|
def _real_initialize(self):
|
||||||
|
if not self._get_cookies('https://vtm.be/').get('authId'):
|
||||||
|
self.raise_login_required()
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
uuid = self._match_id(url)
|
uuid = self._match_id(url)
|
||||||
video = self._download_json(
|
webpage = self._download_webpage(url, uuid)
|
||||||
'https://omc4vm23offuhaxx6hekxtzspi.appsync-api.eu-west-1.amazonaws.com/graphql',
|
apollo_state = self._search_json(
|
||||||
uuid, query={
|
r'window\.__APOLLO_STATE__\s*=', webpage, 'apollo state', uuid)
|
||||||
'query': '''{
|
mychannels_id = traverse_obj(apollo_state, (
|
||||||
getComponent(type: Video, uuid: "%s") {
|
f'Video:{{"uuid":"{uuid}"}}', 'myChannelsVideo', {str_or_none}, {require('mychannels ID')}))
|
||||||
... on Video {
|
|
||||||
description
|
|
||||||
duration
|
|
||||||
myChannelsVideo
|
|
||||||
program {
|
|
||||||
title
|
|
||||||
}
|
|
||||||
publishedAt
|
|
||||||
title
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}''' % uuid, # noqa: UP031
|
|
||||||
}, headers={
|
|
||||||
'x-api-key': 'da2-lz2cab4tfnah3mve6wiye4n77e',
|
|
||||||
})['data']['getComponent']
|
|
||||||
|
|
||||||
return {
|
return self._extract_from_mychannels_api(mychannels_id)
|
||||||
'_type': 'url',
|
|
||||||
'id': uuid,
|
|
||||||
'title': video.get('title'),
|
|
||||||
'url': 'http://mychannels.video/embed/%d' % video['myChannelsVideo'],
|
|
||||||
'description': video.get('description'),
|
|
||||||
'timestamp': parse_iso8601(video.get('publishedAt')),
|
|
||||||
'duration': int_or_none(video.get('duration')),
|
|
||||||
'series': try_get(video, lambda x: x['program']['title']),
|
|
||||||
'ie_key': 'Medialaan',
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue