diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 125568305..10ca1257f 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -1784,10 +1784,6 @@ def _search_nextjs_v13_data(self, webpage, video_id, fatal=True): nextjs_data = [] if not fatal and not isinstance(webpage, str): return nextjs_data - # This regex pattern can afford to be and should be strict - # Ref: https://github.com/vercel/next.js/commit/5a4a08fdce91a038f2ed3a70568d3ed040403150 - # /packages/next/src/server/app-render/use-flight-response.tsx - flight_segments = re.findall(r']*>self\.__next_f\.push\((\[.+?\])\)', webpage) def flatten(flight_data): if not isinstance(flight_data, list) or not flight_data: @@ -1805,7 +1801,10 @@ def flatten(flight_data): for f in flight_data: flatten(f) - for flight_segment in flight_segments: + # The flight segments regex pattern can afford to be (and should be) strict + # Ref: https://github.com/vercel/next.js/commit/5a4a08fdce91a038f2ed3a70568d3ed040403150 + # /packages/next/src/server/app-render/use-flight-response.tsx + for flight_segment in re.findall(r']*>self\.__next_f\.push\((\[.+?\])\)', webpage): segment = self._parse_json(flight_segment, video_id, fatal=fatal, errnote=None if fatal else False) # Some earlier versions of next.js "optimized" away this array structure; this is unsupported # Ref: https://github.com/vercel/next.js/commit/0123a9d5c9a9a77a86f135b7ae30b46ca986d761