Compare commits

..

3 Commits

Author SHA1 Message Date
時流
fd6888d6b2 [ie/litv] Remove unnecessary functools 2024-11-16 12:50:35 +08:00
時流
b0f4f71a10 [ie/litv] Remove unnecessary object traversal 2024-11-16 12:50:35 +08:00
時流
81c2c60073 [ie/litv] Fix comments 2024-11-16 12:50:35 +08:00

View File

@ -1,4 +1,3 @@
import functools
import json import json
import uuid import uuid
@ -73,17 +72,17 @@ class LiTVIE(InfoExtractor):
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
vod_data = self._search_nextjs_data(webpage, video_id, default={}) vod_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']
program_info = traverse_obj(vod_data, ('props', 'pageProps', 'programInformation', {dict})) or {} program_info = traverse_obj(vod_data, ('programInformation', {dict})) or {}
playlist_data = traverse_obj(vod_data, ('props', 'pageProps', 'seriesTree')) playlist_data = traverse_obj(vod_data, ('seriesTree'))
if playlist_data is not None and self._yes_playlist(program_info.get('series_id'), video_id, smuggled_data): if playlist_data is not None and self._yes_playlist(program_info.get('series_id'), video_id, smuggled_data):
return self._extract_playlist(playlist_data, program_info.get('content_type')) return self._extract_playlist(playlist_data, program_info.get('content_type'))
asset_id = traverse_obj(program_info, ('assets', 0, 'asset_id', {str})) asset_id = traverse_obj(program_info, ('assets', 0, 'asset_id', {str}))
if asset_id: # This is a live stream if asset_id: # This is a VOD
media_type = 'vod' media_type = 'vod'
else: # This is a VOD else: # This is a live stream
asset_id = program_info['content_id'] asset_id = program_info['content_id']
media_type = program_info['content_type'] media_type = program_info['content_type']
puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value) puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
@ -117,7 +116,7 @@ class LiTVIE(InfoExtractor):
'title': join_nonempty('title', 'secondary_mark', delim='', from_dict=program_info), 'title': join_nonempty('title', 'secondary_mark', delim='', from_dict=program_info),
**traverse_obj(program_info, { **traverse_obj(program_info, {
'description': ('description', {str}), 'description': ('description', {str}),
'thumbnail': ('picture', {functools.partial(urljoin, 'https://p-cdnstatic.svc.litv.tv/')}), 'thumbnail': ('picture', {urljoin('https://p-cdnstatic.svc.litv.tv/')}),
'categories': ('genres', ..., 'name', {str}), 'categories': ('genres', ..., 'name', {str}),
'episode_number': ('episode', {int_or_none}), 'episode_number': ('episode', {int_or_none}),
}), }),