From c748eca829194de5aba9a66035549f2b9112aba2 Mon Sep 17 00:00:00 2001 From: Bart Broere Date: Sun, 20 Oct 2024 11:49:09 +0200 Subject: [PATCH] Automatically obtain NextJS buildId and change item to video-item --- youtube_dl/extractor/npo.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/npo.py b/youtube_dl/extractor/npo.py index e130f2dbd..8299bfb16 100644 --- a/youtube_dl/extractor/npo.py +++ b/youtube_dl/extractor/npo.py @@ -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, '