3 from .common
import InfoExtractor
14 class IxiguaIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:\w+\.)?ixigua\.com/(?:video/)?(?P<id>\d+).+'
17 'url': 'https://www.ixigua.com/6996881461559165471',
19 'id': '6996881461559165471',
21 'title': '盲目涉水风险大,亲身示范高水位行车注意事项',
22 'description': 'md5:8c82f46186299add4a1c455430740229',
23 'tags': ['video_car'],
28 'uploader_id': '6480145787',
29 'thumbnail': r
're:^https?://.+\.(avif|webp)',
30 'timestamp': 1629088414,
35 def _get_json_data(self
, webpage
, video_id
):
36 js_data
= get_element_by_id('SSR_HYDRATED_DATA', webpage
)
38 if self
._cookies
_passed
:
39 raise ExtractorError('Failed to get SSR_HYDRATED_DATA')
40 raise ExtractorError('Cookies (not necessarily logged in) are needed', expected
=True)
42 return self
._parse
_json
(
43 js_data
.replace('window._SSR_HYDRATED_DATA=', ''), video_id
, transform_source
=js_to_json
)
45 def _media_selector(self
, json_data
):
46 for path
, override
in (
47 (('video_list', ), {}),
48 (('dynamic_video', 'dynamic_video_list'), {'acodec': 'none'}),
49 (('dynamic_video', 'dynamic_audio_list'), {'vcodec': 'none', 'ext': 'm4a'}),
51 for media
in traverse_obj(json_data
, (..., *path
, lambda _
, v
: v
['main_url'])):
53 'url': base64
.b64decode(media
['main_url']).decode(),
54 'width': int_or_none(media
.get('vwidth')),
55 'height': int_or_none(media
.get('vheight')),
56 'fps': int_or_none(media
.get('fps')),
57 'vcodec': media
.get('codec_type'),
58 'format_id': str_or_none(media
.get('quality_type')),
59 'filesize': int_or_none(media
.get('size')),
64 def _real_extract(self
, url
):
65 video_id
= self
._match
_id
(url
)
66 webpage
= self
._download
_webpage
(url
, video_id
)
67 json_data
= self
._get
_json
_data
(webpage
, video_id
)['anyVideo']['gidInformation']['packerData']['video']
69 formats
= list(self
._media
_selector
(json_data
.get('videoResource')))
72 'title': json_data
.get('title'),
73 'description': json_data
.get('video_abstract'),
75 'like_count': json_data
.get('video_like_count'),
76 'duration': int_or_none(json_data
.get('duration')),
77 'tags': [json_data
.get('tag')],
78 'uploader_id': traverse_obj(json_data
, ('user_info', 'user_id')),
79 'uploader': traverse_obj(json_data
, ('user_info', 'name')),
80 'view_count': json_data
.get('video_watch_count'),
81 'dislike_count': json_data
.get('video_unlike_count'),
82 'timestamp': int_or_none(json_data
.get('video_publish_time')),