mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 21:23:05 +00:00
feat: add embed player handler
This commit is contained in:
parent
9c2a6fa449
commit
0639489bc5
@ -1,7 +1,7 @@
|
||||
from .common import InfoExtractor
|
||||
from .piaulizaportal import PIAULIZAPortalAPIIE
|
||||
from ..networking import Request
|
||||
from ..utils import multipart_encode, smuggle_url
|
||||
from ..utils import ExtractorError, multipart_encode, smuggle_url
|
||||
|
||||
|
||||
class PiaLiveIE(InfoExtractor):
|
||||
@ -9,6 +9,21 @@ class PiaLiveIE(InfoExtractor):
|
||||
PIA_LIVE_API_URL = 'https://api.pia-live.jp'
|
||||
_VALID_URL = r'https?://player\.pia-live\.jp/stream/(?P<id>[\w-]+)'
|
||||
|
||||
def handle_embed_player(self, player_tag, video_id, info_dict={}):
|
||||
player_data_url = self._search_regex([PIAULIZAPortalAPIIE.TAG_REGEX_PATTERN],
|
||||
player_tag, 'player data url', fatal=False)
|
||||
|
||||
if PIAULIZAPortalAPIIE.BASE_URL in player_data_url:
|
||||
return self.url_result(
|
||||
smuggle_url(
|
||||
player_data_url,
|
||||
{'video_id': video_id, 'referer': self.PLAYER_ROOT_URL, 'info_dict': info_dict},
|
||||
),
|
||||
ie=PIAULIZAPortalAPIIE.ie_key(),
|
||||
)
|
||||
|
||||
raise ExtractorError('Unsupported streaming platform', expected=True)
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_key = self._match_id(url)
|
||||
webpage = self._download_webpage(url, video_key)
|
||||
@ -38,18 +53,11 @@ class PiaLiveIE(InfoExtractor):
|
||||
program_code,
|
||||
)
|
||||
|
||||
player_data_url = self._search_regex(PIAULIZAPortalAPIIE.SCRIPT_TAG_REGEX_PATTERN,
|
||||
player_tag_list['data']['movie_one_tag'], 'player data url')
|
||||
|
||||
return {
|
||||
**self.url_result(
|
||||
smuggle_url(
|
||||
player_data_url,
|
||||
{'video_id': program_code, 'referer': self.PLAYER_ROOT_URL, 'info_dict': {
|
||||
return self.handle_embed_player(
|
||||
player_tag_list['data']['movie_one_tag'],
|
||||
video_id=program_code,
|
||||
info_dict={
|
||||
'id': program_code,
|
||||
'title': self._html_extract_title(webpage),
|
||||
}},
|
||||
),
|
||||
ie=PIAULIZAPortalAPIIE.ie_key(),
|
||||
),
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -4,7 +4,8 @@ from ..utils import ExtractorError, int_or_none, parse_qs, smuggle_url, time_sec
|
||||
|
||||
class PIAULIZAPortalAPIIE(InfoExtractor):
|
||||
IE_DESC = 'https://player-api.p.uliza.jp - PIA ULIZA m3u8'
|
||||
SCRIPT_TAG_REGEX_PATTERN = r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/[^"]+)"'
|
||||
BASE_URL = 'https://player-api.p.uliza.jp'
|
||||
TAG_REGEX_PATTERN = 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 = [
|
||||
@ -112,7 +113,7 @@ class PIAULIZAPortalIE(InfoExtractor):
|
||||
webpage = self._download_webpage(url, video_id)
|
||||
|
||||
player_data_url = self._search_regex(
|
||||
PIAULIZAPortalAPIIE.SCRIPT_TAG_REGEX_PATTERN,
|
||||
PIAULIZAPortalAPIIE.TAG_REGEX_PATTERN,
|
||||
webpage, 'player data url')
|
||||
return self.url_result(
|
||||
smuggle_url(
|
||||
|
Loading…
Reference in New Issue
Block a user