mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-26 02:37:41 +00:00
Use program-detail endpoint and remove a test
This commit is contained in:
parent
d426a92a60
commit
3b3d73cbe6
1 changed files with 24 additions and 37 deletions
|
@ -25,18 +25,6 @@ class NPOIE(InfoExtractor):
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://npo.nl/start/serie/zembla/seizoen-2015/wie-is-de-mol-2/',
|
'url': 'https://npo.nl/start/serie/zembla/seizoen-2015/wie-is-de-mol-2/',
|
||||||
# TODO fill in other test attributes
|
# TODO fill in other test attributes
|
||||||
}, {
|
|
||||||
'url': 'http://www.npo.nl/de-mega-mike-mega-thomas-show/27-02-2009/VARA_101191800',
|
|
||||||
'md5': 'da50a5787dbfc1603c4ad80f31c5120b',
|
|
||||||
'info_dict': {
|
|
||||||
'id': 'VARA_101191800',
|
|
||||||
'ext': 'm4v',
|
|
||||||
'title': 'De Mega Mike & Mega Thomas show: The best of.',
|
|
||||||
'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4',
|
|
||||||
'upload_date': '20090227',
|
|
||||||
'duration': 2400,
|
|
||||||
},
|
|
||||||
'skip': 'Video gone',
|
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://npo.nl/start/serie/vpro-tegenlicht/seizoen-11/zwart-geld-de-toekomst-komt-uit-afrika',
|
'url': 'https://npo.nl/start/serie/vpro-tegenlicht/seizoen-11/zwart-geld-de-toekomst-komt-uit-afrika',
|
||||||
'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
|
'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
|
||||||
|
@ -66,27 +54,21 @@ class NPOIE(InfoExtractor):
|
||||||
url = url[:-10]
|
url = url[:-10]
|
||||||
url = url.rstrip('/')
|
url = url.rstrip('/')
|
||||||
slug = url.split('/')[-1]
|
slug = url.split('/')[-1]
|
||||||
page = self._download_webpage(url, slug, 'Finding productId using slug: %s' % slug)
|
|
||||||
# TODO find out what proper HTML parsing utilities are available in youtube-dl
|
program_metadata = self._download_json('https://npo.nl/start/api/domain/program-detail',
|
||||||
next_data = page.split('<script id="__NEXT_DATA__" type="application/json">')[1].split('</script>')[0]
|
slug,
|
||||||
# TODO The data in this script tag feels like GraphQL, so there might be an easier way
|
query={'slug': slug})
|
||||||
# to get the product id, maybe using a GraphQL endpoint
|
product_id = program_metadata.get('productId')
|
||||||
next_data = self._parse_json(next_data, slug)
|
images = program_metadata.get('images')
|
||||||
product_id, title, description, thumbnail = None, None, None, None
|
thumbnail = None
|
||||||
for query in next_data['props']['pageProps']['dehydratedState']['queries']:
|
for image in images:
|
||||||
if isinstance(query['state']['data'], list):
|
thumbnail = image.get('url')
|
||||||
for entry in query['state']['data']:
|
break
|
||||||
if entry['slug'] == slug:
|
title = program_metadata.get('title')
|
||||||
product_id = entry.get('productId')
|
descriptions = program_metadata.get('description', {})
|
||||||
title = entry.get('title')
|
description = descriptions.get('long') or descriptions.get('short') or descriptions.get('brief')
|
||||||
synopsis = entry.get('synopsis', {})
|
duration = program_metadata.get('durationInSeconds')
|
||||||
description = (synopsis.get('long')
|
|
||||||
or synopsis.get('short')
|
|
||||||
or synopsis.get('brief'))
|
|
||||||
thumbnails = entry.get('images')
|
|
||||||
for thumbnail_entry in thumbnails:
|
|
||||||
if 'url' in thumbnail_entry:
|
|
||||||
thumbnail = thumbnail_entry.get('url')
|
|
||||||
if not product_id:
|
if not product_id:
|
||||||
raise ExtractorError('No productId found for slug: %s' % slug)
|
raise ExtractorError('No productId found for slug: %s' % slug)
|
||||||
|
|
||||||
|
@ -96,9 +78,9 @@ class NPOIE(InfoExtractor):
|
||||||
'id': slug,
|
'id': slug,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'title': title or slug,
|
'title': title or slug,
|
||||||
'description': description,
|
'description': description or title or slug,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
# TODO fill in other metadata that's available
|
'duration': duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _download_by_product_id(self, product_id, slug, url=None):
|
def _download_by_product_id(self, product_id, slug, url=None):
|
||||||
|
@ -106,7 +88,8 @@ class NPOIE(InfoExtractor):
|
||||||
formats = []
|
formats = []
|
||||||
for profile in (
|
for profile in (
|
||||||
'dash',
|
'dash',
|
||||||
# 'hls', # TODO test what needs to change for 'hls' support
|
# 'hls' is available too, but implementing it doesn't add much
|
||||||
|
# As far as I know 'dash' is always available
|
||||||
):
|
):
|
||||||
stream_link = self._download_json(
|
stream_link = self._download_json(
|
||||||
'https://prod.npoplayer.nl/stream-link', video_id=slug,
|
'https://prod.npoplayer.nl/stream-link', video_id=slug,
|
||||||
|
@ -131,6 +114,7 @@ class BNNVaraIE(NPOIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?bnnvara\.nl/videos/[0-9]*'
|
_VALID_URL = r'https?://(?:www\.)?bnnvara\.nl/videos/[0-9]*'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.bnnvara.nl/videos/27455',
|
'url': 'https://www.bnnvara.nl/videos/27455',
|
||||||
|
# TODO fill in other test attributes
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -170,6 +154,7 @@ class ONIE(NPOIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?ongehoordnederland.tv/.*'
|
_VALID_URL = r'https?://(?:www\.)?ongehoordnederland.tv/.*'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://ongehoordnederland.tv/2024/03/01/korte-clips/heeft-preppen-zin-betwijfel-dat-je-daar-echt-iets-aan-zult-hebben-bij-oorlog-lydia-daniel/',
|
'url': 'https://ongehoordnederland.tv/2024/03/01/korte-clips/heeft-preppen-zin-betwijfel-dat-je-daar-echt-iets-aan-zult-hebben-bij-oorlog-lydia-daniel/',
|
||||||
|
# TODO fill in other test attributes
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -196,6 +181,7 @@ class VPROIE(NPOIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?vpro.nl/.*'
|
_VALID_URL = r'https?://(?:www\.)?vpro.nl/.*'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.vpro.nl/programmas/tegenlicht/kijk/afleveringen/2015-2016/offline-als-luxe.html',
|
'url': 'https://www.vpro.nl/programmas/tegenlicht/kijk/afleveringen/2015-2016/offline-als-luxe.html',
|
||||||
|
# TODO fill in other test attributes
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -224,6 +210,7 @@ class ZAPPIE(NPOIE):
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.zapp.nl/programmas/zappsport/gemist/AT_300003973',
|
'url': 'https://www.zapp.nl/programmas/zappsport/gemist/AT_300003973',
|
||||||
|
# TODO fill in other test attributes
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
|
Loading…
Reference in a new issue