Speculate about other ways of getting productId

This commit is contained in:
Bart Broere 2024-03-01 15:08:10 +01:00
parent 0dc7d954cb
commit fb7b7179ff

View File

@ -70,6 +70,8 @@ class NPOIE(InfoExtractor):
page = self._download_webpage(url, slug, 'Finding productId using slug: %s' % slug) 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 # TODO find out what proper HTML parsing utilities are available in youtube-dl
next_data = page.split('<script id="__NEXT_DATA__" type="application/json">')[1].split('</script>')[0] next_data = page.split('<script id="__NEXT_DATA__" type="application/json">')[1].split('</script>')[0]
# TODO The data in this script tag feels like GraphQL, so there might be an easier way
# to get the product id, maybe using a GraphQL endpoint
next_data = json.loads(next_data) next_data = json.loads(next_data)
product_id, title, description, thumbnail = None, None, None, None product_id, title, description, thumbnail = None, None, None, None
for query in next_data['props']['pageProps']['dehydratedState']['queries']: for query in next_data['props']['pageProps']['dehydratedState']['queries']: