mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 21:23:05 +00:00
Apply suggestions from code review
Co-authored-by: sepro <sepro@sepr0.com>
This commit is contained in:
parent
83f4c5a98e
commit
aa410c803b
@ -43,8 +43,8 @@ class PiaLiveIE(InfoExtractor):
|
||||
|
||||
def _extract_vars(self, variable, html):
|
||||
return self._search_regex(
|
||||
rf'(?:var|const)\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
|
||||
html, 'variable', group='value', default=None)
|
||||
rf'(?:var|const|let)\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
|
||||
html, f'variable {variable}', group='value')
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_key = self._match_id(url)
|
||||
@ -53,13 +53,6 @@ class PiaLiveIE(InfoExtractor):
|
||||
program_code = self._extract_vars('programCode', webpage)
|
||||
article_code = self._extract_vars('articleCode', webpage)
|
||||
|
||||
prod_configure = self._download_webpage(
|
||||
self.PLAYER_ROOT_URL + self._search_regex(
|
||||
r'<script[^>]+src=(["\'])(?P<url>/statics/js/s_prod\?(?:(?!\1).)+)\1',
|
||||
webpage, 'prod configure page url', group='url'),
|
||||
program_code, headers={'Referer': self.PLAYER_ROOT_URL},
|
||||
note='Fetching prod configure page', errnote='Unable to fetch prod configure page')
|
||||
|
||||
payload, content_type = multipart_encode({
|
||||
'play_url': video_key,
|
||||
'api_key': self._extract_vars('APIKEY', prod_configure)})
|
||||
|
@ -4,9 +4,7 @@ from ..utils.traversal import traverse_obj
|
||||
|
||||
|
||||
class PIAULIZAPortalAPIIE(InfoExtractor):
|
||||
IE_DESC = 'https://player-api.p.uliza.jp - PIA ULIZA m3u8'
|
||||
|
||||
_VALID_URL = r'https://player-api\.p\.uliza\.jp/v1/players/(?P<id>.*)'
|
||||
_VALID_URL = r'https://player-api\.p\.uliza\.jp/v1/players/[^?#]+\?(?:[^#]*&)?name=(?P<id>[^#&]+)'
|
||||
_TESTS = [
|
||||
{
|
||||
'url': 'https://player-api.p.uliza.jp/v1/players/timeshift-disabled/pia/admin?type=normal&playerobjectname=ulizaPlayer&name=livestream01_dvr&repeatable=true',
|
||||
@ -15,10 +13,6 @@ class PIAULIZAPortalAPIIE(InfoExtractor):
|
||||
'title': '88f3109a-f503-4d0f-a9f7-9f39ac745d84',
|
||||
'live_status': 'was_live',
|
||||
},
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
'ignore_no_formats_error': True,
|
||||
},
|
||||
},
|
||||
{
|
||||
'url': 'https://player-api.p.uliza.jp/v1/players/uliza_jp_gallery_normal/promotion/admin?type=presentation&name=cookings&targetid=player1',
|
||||
@ -47,15 +41,15 @@ class PIAULIZAPortalAPIIE(InfoExtractor):
|
||||
]
|
||||
|
||||
def _real_extract(self, url):
|
||||
tmp_video_id = self._search_regex(r'&name=([^&]+)', self._match_id(url), 'video id', default='unknown')
|
||||
display_id = self._match_id(url)
|
||||
player_data = self._download_webpage(
|
||||
url, tmp_video_id, headers={'Referer': 'https://player-api.p.uliza.jp/'},
|
||||
note='Fetching player data', errnote='Unable to fetch player data',
|
||||
)
|
||||
|
||||
m3u8_url = self._search_regex(
|
||||
r'["\'](https://vms-api\.p\.uliza\.jp/v1/prog-index\.m3u8[^"\']+)', player_data,
|
||||
'm3u8 url', default=None)
|
||||
player_data = self._search_json(
|
||||
r'var\s+params\s*=', player_js, 'json', display_id,
|
||||
transform_source=js_to_json)
|
||||
|
||||
video_id = self._search_regex(r'&?ss=([\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})&?', m3u8_url, 'video id', default=tmp_video_id)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user