1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-22 07:56:49 +00:00

Automatically obtain NextJS buildId and change item to video-item

This commit is contained in:
Bart Broere 2024-10-20 11:49:09 +02:00
parent 6de650f51f
commit c748eca829

View File

@ -221,13 +221,14 @@ class SchoolTVIE(NPOIE):
def _real_extract(self, url):
video_id = url.rstrip('/').split('/')[-1]
# TODO Find out how we could obtain this automatically
# Otherwise this extractor might break each time SchoolTV deploys a new release
build_id = 'b7eHUzAVO7wHXCopYxQhV'
build_id = self._search_nextjs_data(
self._download_webpage(url, video_id),
video_id,
)['buildId']
metadata_url = 'https://schooltv.nl/_next/data/' \
+ build_id \
+ '/item/' \
+ '/video-item/' \
+ video_id + '.json'
metadata = self._download_json(metadata_url,
@ -304,7 +305,7 @@ class VPROIE(NPOIE):
formats = []
for result in results:
formats.extend(self._extract_formats_by_product_id(result, video_id))
break # TODO find a better solution, VPRO pages can have multiple videos embedded
break
if not formats:
raise ExtractorError('Could not find a POMS product id in the provided URL, '