aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsepro <sepro@sepr0.com>2024-09-14 02:15:07 +0200
committerGitHub <noreply@github.com>2024-09-14 00:15:07 +0000
commit3aa0156e05662923d130ddbc1c82596e38c01a00 (patch)
tree1d0b1aa15e72c163bbc395849ecc90dc285d7aab
parent300c91274f7ea5b1b0528fc5ee11cf1a61d4079e (diff)
[ie/Xinpianchang] Fix extractor (#10950)
Authored by: seproDev
-rw-r--r--yt_dlp/extractor/xinpianchang.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/yt_dlp/extractor/xinpianchang.py b/yt_dlp/extractor/xinpianchang.py
index 10849916b..23ed9270d 100644
--- a/yt_dlp/extractor/xinpianchang.py
+++ b/yt_dlp/extractor/xinpianchang.py
@@ -3,16 +3,13 @@ from ..utils import (
int_or_none,
str_or_none,
try_get,
- update_url_query,
url_or_none,
)
class XinpianchangIE(InfoExtractor):
- _WORKING = False
- _VALID_URL = r'https?://www\.xinpianchang\.com/(?P<id>[^/]+?)(?:\D|$)'
- IE_NAME = 'xinpianchang'
- IE_DESC = 'xinpianchang.com'
+ _VALID_URL = r'https?://(www\.)?xinpianchang\.com/(?P<id>a\d+)'
+ IE_DESC = '新片场'
_TESTS = [{
'url': 'https://www.xinpianchang.com/a11766551',
'info_dict': {
@@ -49,11 +46,11 @@ class XinpianchangIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id=video_id)
- domain = self.find_value_with_regex(var='requireNewDomain', webpage=webpage)
- vid = self.find_value_with_regex(var='vid', webpage=webpage)
- app_key = self.find_value_with_regex(var='modeServerAppKey', webpage=webpage)
- api = update_url_query(f'{domain}/mod/api/v2/media/{vid}', {'appKey': app_key})
- data = self._download_json(api, video_id=video_id)['data']
+ video_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['detail']['video']
+
+ data = self._download_json(
+ f'https://mod-api.xinpianchang.com/mod/api/v2/media/{video_data["vid"]}', video_id,
+ query={'appKey': video_data['appKey']})['data']
formats, subtitles = [], {}
for k, v in data.get('resource').items():
if k in ('dash', 'hls'):
@@ -72,6 +69,10 @@ class XinpianchangIE(InfoExtractor):
'width': int_or_none(prog.get('width')),
'height': int_or_none(prog.get('height')),
'ext': 'mp4',
+ 'http_headers': {
+ # NB: Server returns 403 without the Range header
+ 'Range': 'bytes=0-',
+ },
} for prog in v if prog.get('url') or []])
return {
@@ -87,6 +88,3 @@ class XinpianchangIE(InfoExtractor):
'formats': formats,
'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)