mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[ie] Add _search_nextjs_v13_data helper (#13398)
				
					
				
			* Fixes FranceTVSiteIE livestream extraction * Fixes GoPlayIE metadata extraction Authored by: bashonly
This commit is contained in:
		| @@ -1959,6 +1959,32 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/ | ||||
|         with self.assertWarns(DeprecationWarning): | ||||
|             self.assertEqual(self.ie._search_nextjs_data('', None, default='{}'), {}) | ||||
| 
 | ||||
|     def test_search_nextjs_v13_data(self): | ||||
|         HTML = R''' | ||||
|             <script>(self.__next_f=self.__next_f||[]).push([0])</script> | ||||
|             <script>self.__next_f.push([2,"0:[\"$\",\"$L0\",null,{\"do_not_add_this\":\"fail\"}]\n"])</script> | ||||
|             <script>self.__next_f.push([1,"1:I[46975,[],\"HTTPAccessFallbackBoundary\"]\n2:I[32630,[\"8183\",\"static/chunks/8183-768193f6a9e33cdd.js\"]]\n"])</script> | ||||
|             <script nonce="abc123">self.__next_f.push([1,"e:[false,[\"$\",\"div\",null,{\"children\":[\"$\",\"$L18\",null,{\"foo\":\"bar\"}]}],false]\n    "])</script> | ||||
|             <script>self.__next_f.push([1,"2a:[[\"$\",\"div\",null,{\"className\":\"flex flex-col\",\"children\":[]}],[\"$\",\"$L16\",null,{\"meta\":{\"dateCreated\":1730489700,\"uuid\":\"40cac41d-8d29-4ef5-aa11-75047b9f0907\"}}]]\n"])</script> | ||||
|             <script>self.__next_f.push([1,"df:[\"$undefined\",[\"$\",\"div\",null,{\"children\":[\"$\",\"$L17\",null,{}],\"do_not_include_this_field\":\"fail\"}],[\"$\",\"div\",null,{\"children\":[[\"$\",\"$L19\",null,{\"duplicated_field_name\":{\"x\":1}}],[\"$\",\"$L20\",null,{\"duplicated_field_name\":{\"y\":2}}]]}],\"$undefined\"]\n"])</script> | ||||
|             <script>self.__next_f.push([3,"MzM6WyIkIiwiJEwzMiIsbnVsbCx7ImRlY29kZWQiOiJzdWNjZXNzIn1d"])</script> | ||||
|             ''' | ||||
|         EXPECTED = [{ | ||||
|             'foo': 'bar', | ||||
|         }, { | ||||
|             'meta': { | ||||
|                 'dateCreated': 1730489700, | ||||
|                 'uuid': '40cac41d-8d29-4ef5-aa11-75047b9f0907', | ||||
|             }, | ||||
|         }, { | ||||
|             'duplicated_field_name': {'x': 1}, | ||||
|         }, { | ||||
|             'duplicated_field_name': {'y': 2}, | ||||
|         }] | ||||
|         self.assertEqual(self.ie._search_nextjs_v13_data(HTML, None), EXPECTED) | ||||
|         self.assertEqual(self.ie._search_nextjs_v13_data('', None, fatal=False), []) | ||||
|         self.assertEqual(self.ie._search_nextjs_v13_data(None, None, fatal=False), []) | ||||
| 
 | ||||
|     def test_search_nuxt_json(self): | ||||
|         HTML_TMPL = '<script data-ssr="true" id="__NUXT_DATA__" type="application/json">[{}]</script>' | ||||
|         VALID_DATA = ''' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 bashonly
					bashonly