mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 20:38:11 -05:00
parent
300c91274f
commit
3aa0156e05
1 changed files with 11 additions and 13 deletions
|
@ -3,16 +3,13 @@
|
||||||
int_or_none,
|
int_or_none,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
update_url_query,
|
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class XinpianchangIE(InfoExtractor):
|
class XinpianchangIE(InfoExtractor):
|
||||||
_WORKING = False
|
_VALID_URL = r'https?://(www\.)?xinpianchang\.com/(?P<id>a\d+)'
|
||||||
_VALID_URL = r'https?://www\.xinpianchang\.com/(?P<id>[^/]+?)(?:\D|$)'
|
IE_DESC = '新片场'
|
||||||
IE_NAME = 'xinpianchang'
|
|
||||||
IE_DESC = 'xinpianchang.com'
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.xinpianchang.com/a11766551',
|
'url': 'https://www.xinpianchang.com/a11766551',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -49,11 +46,11 @@ class XinpianchangIE(InfoExtractor):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id=video_id)
|
webpage = self._download_webpage(url, video_id=video_id)
|
||||||
domain = self.find_value_with_regex(var='requireNewDomain', webpage=webpage)
|
video_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['detail']['video']
|
||||||
vid = self.find_value_with_regex(var='vid', webpage=webpage)
|
|
||||||
app_key = self.find_value_with_regex(var='modeServerAppKey', webpage=webpage)
|
data = self._download_json(
|
||||||
api = update_url_query(f'{domain}/mod/api/v2/media/{vid}', {'appKey': app_key})
|
f'https://mod-api.xinpianchang.com/mod/api/v2/media/{video_data["vid"]}', video_id,
|
||||||
data = self._download_json(api, video_id=video_id)['data']
|
query={'appKey': video_data['appKey']})['data']
|
||||||
formats, subtitles = [], {}
|
formats, subtitles = [], {}
|
||||||
for k, v in data.get('resource').items():
|
for k, v in data.get('resource').items():
|
||||||
if k in ('dash', 'hls'):
|
if k in ('dash', 'hls'):
|
||||||
|
@ -72,6 +69,10 @@ def _real_extract(self, url):
|
||||||
'width': int_or_none(prog.get('width')),
|
'width': int_or_none(prog.get('width')),
|
||||||
'height': int_or_none(prog.get('height')),
|
'height': int_or_none(prog.get('height')),
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
|
'http_headers': {
|
||||||
|
# NB: Server returns 403 without the Range header
|
||||||
|
'Range': 'bytes=0-',
|
||||||
|
},
|
||||||
} for prog in v if prog.get('url') or []])
|
} for prog in v if prog.get('url') or []])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -87,6 +88,3 @@ def _real_extract(self, url):
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
def find_value_with_regex(self, var, webpage):
|
|
||||||
return self._search_regex(rf'var\s{var}\s=\s\"(?P<vid>[^\"]+)\"', webpage, name=var)
|
|
||||||
|
|
Loading…
Reference in a new issue