mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-23 13:48:30 +00:00
Fix zapp.nl extractor
This commit is contained in:
parent
8623235006
commit
ac48f25f8f
@ -1,15 +1,15 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from yt_dlp.utils._utils import ExtractorError
|
|
||||||
from yt_dlp.utils.traversal import traverse_obj
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
|
extract_attributes,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
)
|
)
|
||||||
|
from ..utils.traversal import find_element, traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class NPOBaseIE(InfoExtractor):
|
class NPOBaseIE(InfoExtractor):
|
||||||
@ -35,6 +35,8 @@ def _extract_info_from_token(self, video_id, token):
|
|||||||
headers={'Authorization': token},
|
headers={'Authorization': token},
|
||||||
fatal=False,
|
fatal=False,
|
||||||
)
|
)
|
||||||
|
if not profile:
|
||||||
|
continue
|
||||||
metadata = profile.get('metadata')
|
metadata = profile.get('metadata')
|
||||||
if metadata is not None:
|
if metadata is not None:
|
||||||
duration = metadata.get('duration')
|
duration = metadata.get('duration')
|
||||||
@ -300,23 +302,28 @@ class ZappIE(NPOBaseIE):
|
|||||||
_VALID_URL = r'https?://(?:www\.)?zapp\.nl/programmas/(?:[^/]+/){2}(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?://(?:www\.)?zapp\.nl/programmas/(?:[^/]+/){2}(?P<id>[^/?#&]+)'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.zapp.nl/programmas/zappsport/gemist/POMS_AT_811523',
|
'url': 'https://www.zapp.nl/programmas/zappsport/gemist/POMS_AT_876597',
|
||||||
'md5': 'faf6811abea03ba8a52298c97bd0146b',
|
'md5': '7daa619e7c01ea7f6abd528eaf1af4c4',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'POMS_AT_811523',
|
'id': 'POMS_AT_876597',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
|
'title': 'Bommetje! - clip 1',
|
||||||
|
'duration': 13.0,
|
||||||
|
'thumbnail': 'https://images.poms.omroep.nl/image/s1080/615088',
|
||||||
'genres': [],
|
'genres': [],
|
||||||
'uploader_id': 'NED3',
|
|
||||||
'description': 'Kindersportprogramma waarin alle takken van sport voorbijkomen.',
|
|
||||||
'channel_id': 'NED3',
|
|
||||||
'thumbnail': 'https://images.poms.omroep.nl/image/s1080/586056',
|
|
||||||
'duration': 900.0,
|
|
||||||
'title': 'Running Team 2015 - aflevering 1',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
return self._extract_product_id_information(self._match_id(url))
|
video_id = self._match_id(url)
|
||||||
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
payload = traverse_obj(webpage, (
|
||||||
|
{find_element(attr='data-react-class', value='Player', html=True)},
|
||||||
|
{extract_attributes}, 'data-react-props', {json.loads}))['player_token_payload']
|
||||||
|
token = self._download_json(
|
||||||
|
'https://www.zapp.nl/api/v5/player_tokens', video_id, 'Downloading token',
|
||||||
|
data=json.dumps({'payload': payload}).encode(), headers={'content-type': 'application/json'})['token']
|
||||||
|
return self._extract_info_from_token(video_id, token)
|
||||||
|
|
||||||
|
|
||||||
class NPOPlaylistBaseIE(NPOBaseIE):
|
class NPOPlaylistBaseIE(NPOBaseIE):
|
||||||
|
Loading…
Reference in New Issue
Block a user