From 6857112a21493eaaf1d00ac9051a69b15805b563 Mon Sep 17 00:00:00 2001 From: bashonly Date: Mon, 9 Jun 2025 15:29:39 -0500 Subject: [PATCH] rearrange Authored by: bashonly --- yt_dlp/extractor/common.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 553d53e42..2c157ba2f 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -1801,6 +1801,13 @@ def _search_nuxt_json(self, webpage, video_id, *, fatal=True, default=NO_DEFAULT # https://github.com/nuxt/nuxt/pull/19205 IGNORED_TYPES = ('Map', 'Set', 'Ref', 'ShallowRef', 'EmptyRef', 'EmptyShallowRef', 'NuxtError') + if default is not NO_DEFAULT: + fatal = False + + array = self._search_json( + r']+\bid="__NUXT_DATA__"[^>]*>', webpage, 'Nuxt JSON data', video_id, + contains_pattern=r'\[(?s:.+)\]', default=NO_DEFAULT if fatal else []) + def extract_element(element): if isinstance(element, list): if element and isinstance(element[0], str): @@ -1819,13 +1826,6 @@ def extract_element(element): return ret return element - if default is not NO_DEFAULT: - fatal = False - - array = self._search_json( - r']+\bid="__NUXT_DATA__"[^>]*>', webpage, 'Nuxt JSON data', video_id, - contains_pattern=r'\[(?s:.+)\]', default=NO_DEFAULT if fatal else []) - try: return extract_element(array[0]) except IndexError: