chore: rename regex and add referer

This commit is contained in:
ChocoLZS 2024-08-22 19:51:05 +08:00
parent 3fa3edc3c4
commit 1a16c62638
2 changed files with 6 additions and 11 deletions

View file

@ -36,10 +36,10 @@ class PiaLiveIE(InfoExtractor):
]
def handle_embed_player(self, player_tag, video_id, info_dict={}):
player_data_url = self._search_regex([PIAULIZAPortalAPIIE.TAG_REGEX_PATTERN],
player_data_url = self._search_regex([PIAULIZAPortalAPIIE.TAG_REGEX],
player_tag, 'player data url', fatal=False)
if PIAULIZAPortalAPIIE.BASE_URL in player_data_url:
if player_data_url.startswith(PIAULIZAPortalAPIIE.BASE_URL):
return self.url_result(
smuggle_url(
player_data_url,
@ -57,8 +57,7 @@ def _real_extract(self, url):
prod_configure = self._download_webpage(
self.PLAYER_ROOT_URL + self._search_regex(r'<script [^>]*\bsrc="(/statics/js/s_prod[^"]+)"', webpage, 'prod configure page'),
program_code,
headers={'Referer': self.PLAYER_ROOT_URL},
program_code, headers={'Referer': self.PLAYER_ROOT_URL},
note='Fetching prod configure page', errnote='Unable to fetch prod configure page',
)
@ -69,11 +68,7 @@ def _real_extract(self, url):
})
player_tag_list = self._download_json(
f'{self.PIA_LIVE_API_URL}/perf/player-tag-list/{program_code}',
program_code,
data=payload,
headers={
'Content-Type': content_type,
},
program_code, data=payload, headers={'Content-Type': content_type, 'Referer': self.PLAYER_ROOT_URL},
)
return self.handle_embed_player(

View file

@ -5,7 +5,7 @@
class PIAULIZAPortalAPIIE(InfoExtractor):
IE_DESC = 'https://player-api.p.uliza.jp - PIA ULIZA m3u8'
BASE_URL = 'https://player-api.p.uliza.jp'
TAG_REGEX_PATTERN = r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/[^"]+)"'
TAG_REGEX = r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/[^"]+)"'
_VALID_URL = r'https://player-api\.p\.uliza\.jp/v1/players/(?P<id>.*)'
_TESTS = [
@ -117,7 +117,7 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
player_data_url = self._search_regex(
PIAULIZAPortalAPIIE.TAG_REGEX_PATTERN,
PIAULIZAPortalAPIIE.TAG_REGEX,
webpage, 'player data url')
return self.url_result(
smuggle_url(