Compare commits

...

6 Commits

Author SHA1 Message Date
時流
1fdfb4d65d [litv] Handle slight variations of meta refresh
Just in case litv.tv make some changes to their meta refresh tag.
2023-09-26 12:10:22 +00:00
時流
66c246f124 [litv] Restore unit test
I removed this test in [1] because the video no longer exists.
I am now restoring it using a different 'skip' reason.

[1] aa6e612a8c
2023-09-26 11:33:35 +00:00
時流
70093357ba [litv] Make use of traverse_obj 2023-09-26 11:05:49 +00:00
時流
087c2a919a [litv] Remove unnecessary variables 2023-09-26 10:54:17 +00:00
時流
7668f71a3b [litv] Rename variable
Rename seasons_list var since it is not actually a list.
2023-09-26 10:52:08 +00:00
時流
2f2cd22571 [litv] Remove unnecessary header
This header is being sent out by browsers,
but the extractor also work fine without it.
2023-09-26 10:49:35 +00:00

View File

@ -6,6 +6,7 @@ from ..utils import (
int_or_none,
smuggle_url,
unsmuggle_url,
traverse_obj,
)
@ -38,20 +39,26 @@ class LiTVIE(InfoExtractor):
'noplaylist': True,
},
'skip': 'Georestricted to Taiwan',
}, {
'url': 'https://www.litv.tv/promo/miyuezhuan/?content_id=VOD00044841&',
'md5': '88322ea132f848d6e3e18b32a832b918',
'info_dict': {
'id': 'VOD00044841',
'ext': 'mp4',
'title': '芈月傳第1集 霸星芈月降世楚國',
'description': '楚威王二年,太史令唐昧夜觀星象,發現霸星即將現世。王后得知霸星的預言後,想盡辦法不讓孩子順利出生,幸得莒姬相護化解危機。沒想到眾人期待下出生的霸星卻是位公主,楚威王對此失望至極。楚王后命人將女嬰丟棄河中,居然奇蹟似的被少司命像攔下,楚威王認為此女非同凡響,為她取名芈月。',
},
'skip': 'No longer exists',
}]
def _extract_playlist(self, seasons_list, content_type):
episode_title = seasons_list['title']
content_id = seasons_list['contentId']
def _extract_playlist(self, playlist_data, content_type):
all_episodes = [
self.url_result(smuggle_url(
self._URL_TEMPLATE % (content_type, episode['contentId']),
{'force_noplaylist': True})) # To prevent infinite recursion
for season in seasons_list['seasons']
for episode in season['episode']]
for episode in traverse_obj(playlist_data, ('seasons', ..., 'episode', lambda _, v: v['contentId']))]
return self.playlist_result(all_episodes, content_id, episode_title)
return self.playlist_result(all_episodes, playlist_data['contentId'], playlist_data['title'])
def _real_extract(self, url):
url, smuggled_data = unsmuggle_url(url, {})
@ -60,7 +67,9 @@ class LiTVIE(InfoExtractor):
webpage = self._download_webpage(url, video_id)
if '<meta http-equiv="refresh" content="1;url=https://www.litv.tv/"' in webpage:
if self._search_regex(
r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
webpage, 'meta refresh redirect', default=False, group=0):
raise ExtractorError('No such content', expected=True)
program_info = self._parse_json(self._search_regex(
@ -74,8 +83,7 @@ class LiTVIE(InfoExtractor):
program_info = self._download_json(
'https://www.litv.tv/vod/ajax/getProgramInfo', video_id,
query={'contentId': video_id},
headers={'Content-Type': 'application/json',
'Accept': 'application/json'})
headers={'Accept': 'application/json'})
series_id = program_info['seriesId']
if self._yes_playlist(series_id, video_id, smuggled_data):
@ -83,8 +91,7 @@ class LiTVIE(InfoExtractor):
'https://www.litv.tv/vod/ajax/getSeriesTree',
video_id,
query={'seriesId': series_id},
headers={'Content-Type': 'application/json',
'Accept': 'application/json'})
headers={'Accept': 'application/json'})
return self._extract_playlist(playlist_data, program_info['contentType'])
video_data = self._parse_json(self._search_regex(