mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-25 02:45:12 +00:00
[extractor/tempo] Add IVXPlayer extractor (#5837)
Authored by: HobbyistDev
This commit is contained in:
parent
9acca71237
commit
30031be974
2 changed files with 91 additions and 30 deletions
|
@ -1858,7 +1858,7 @@
|
||||||
)
|
)
|
||||||
from .teletask import TeleTaskIE
|
from .teletask import TeleTaskIE
|
||||||
from .telewebion import TelewebionIE
|
from .telewebion import TelewebionIE
|
||||||
from .tempo import TempoIE
|
from .tempo import TempoIE, IVXPlayerIE
|
||||||
from .tencent import (
|
from .tencent import (
|
||||||
IflixEpisodeIE,
|
IflixEpisodeIE,
|
||||||
IflixSeriesIE,
|
IflixSeriesIE,
|
||||||
|
|
|
@ -1,5 +1,81 @@
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import int_or_none, parse_iso8601, str_or_none, traverse_obj
|
from ..utils import (
|
||||||
|
int_or_none,
|
||||||
|
parse_iso8601,
|
||||||
|
traverse_obj,
|
||||||
|
try_call
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class IVXPlayerIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'ivxplayer:(?P<video_id>\d+):(?P<player_key>\w+)'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'ivxplayer:2366065:4a89dfe6bc8f002596b1dfbd600730b1',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '2366065',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'duration': 112,
|
||||||
|
'upload_date': '20221204',
|
||||||
|
'title': 'Film Indonesia di Disney Content Showcase Asia Pacific 2022',
|
||||||
|
'timestamp': 1670151746,
|
||||||
|
'thumbnail': 'https://ivx-image.ivideosmart.com/serve/image/video/2366065?width=300'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
_WEBPAGE_TESTS = [{
|
||||||
|
'url': 'https://www.cantika.com/video/31737/film-indonesia-di-disney-content-showcase-asia-pacific-2022',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '2374200',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'duration': 110,
|
||||||
|
'title': 'Serial Indonesia di Disney Content Showcase Asia Pacific 2022',
|
||||||
|
'timestamp': 1670639416,
|
||||||
|
'upload_date': '20221210',
|
||||||
|
'thumbnail': 'https://ivx-image.ivideosmart.com/serve/image/video/2374200?width=300'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.gooto.com/video/11437/wuling-suv-ramai-dikunjungi-di-giias-2018',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '892109',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Wuling SUV Ramai Dikunjungi di GIIAS 2018',
|
||||||
|
'upload_date': '20180811',
|
||||||
|
'description': 'md5:6d901483d0aacc664aecb4489719aafa',
|
||||||
|
'duration': 75,
|
||||||
|
'timestamp': 1534011263,
|
||||||
|
'thumbnail': 'https://ivx-image.ivideosmart.com/serve/image/video/892109?width=300'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _extract_embed_urls(cls, url, webpage):
|
||||||
|
# more info at https://player.ivideosmart.com/ivsplayer/v4/dist/js/loader.js
|
||||||
|
mobj = re.search(
|
||||||
|
r'<ivs-player\s*[^>]+data-ivs-key\s*=\s*"(?P<player_key>[\w]+)\s*[^>]+\bdata-ivs-vid="(?P<video_id>[\w-]+)',
|
||||||
|
webpage)
|
||||||
|
if mobj:
|
||||||
|
yield f'ivxplayer:{mobj.group("video_id")}:{mobj.group("player_key")}'
|
||||||
|
raise cls.StopExtraction()
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
video_id, player_key = self._match_valid_url(url).group('video_id', 'player_key')
|
||||||
|
json_data = self._download_json(
|
||||||
|
f'https://ivxplayer.ivideosmart.com/prod/video/{video_id}?key={player_key}', video_id)
|
||||||
|
|
||||||
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
|
json_data['player']['video_url'], video_id)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': str(json_data['ivx']['id']),
|
||||||
|
'title': traverse_obj(json_data, ('ivx', 'name')),
|
||||||
|
'description': traverse_obj(json_data, ('ivx', 'description')),
|
||||||
|
'duration': int_or_none(traverse_obj(json_data, ('ivx', 'duration'))),
|
||||||
|
'timestamp': parse_iso8601(traverse_obj(json_data, ('ivx', 'published_at'))),
|
||||||
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
|
'thumbnail': traverse_obj(json_data, ('ivx', 'thumbnail_url'))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TempoIE(InfoExtractor):
|
class TempoIE(InfoExtractor):
|
||||||
|
@ -7,14 +83,14 @@ class TempoIE(InfoExtractor):
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://video.tempo.co/read/30058/anies-baswedan-ajukan-banding-putusan-ptun-batalkan-ump-dki',
|
'url': 'https://video.tempo.co/read/30058/anies-baswedan-ajukan-banding-putusan-ptun-batalkan-ump-dki',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '2144438',
|
'id': '2144275',
|
||||||
|
'display_id': 'anies-baswedan-ajukan-banding-putusan-ptun-batalkan-ump-dki',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Anies Baswedan Ajukan Banding Putusan PTUN Batalkan UMP DKI',
|
'title': 'Anies Baswedan Ajukan Banding Putusan PTUN Batalkan UMP DKI',
|
||||||
'display_id': 'anies-baswedan-ajukan-banding-putusan-ptun-batalkan-ump-dki',
|
'duration': 85,
|
||||||
'duration': 84,
|
|
||||||
'description': 'md5:a6822b7c4c874fa7e5bd63e96a387b66',
|
'description': 'md5:a6822b7c4c874fa7e5bd63e96a387b66',
|
||||||
'thumbnail': 'https://statik.tempo.co/data/2022/07/27/id_1128287/1128287_720.jpg',
|
'thumbnail': 'https://statik.tempo.co/data/2022/07/27/id_1128287/1128287_720.jpg',
|
||||||
'timestamp': 1658911277,
|
'timestamp': 1658907970,
|
||||||
'upload_date': '20220727',
|
'upload_date': '20220727',
|
||||||
'tags': ['Anies Baswedan', ' PTUN', ' PTUN | Pengadilan Tata Usaha Negara', ' PTUN Batalkan UMP DKI', ' UMP DKI'],
|
'tags': ['Anies Baswedan', ' PTUN', ' PTUN | Pengadilan Tata Usaha Negara', ' PTUN Batalkan UMP DKI', ' UMP DKI'],
|
||||||
}
|
}
|
||||||
|
@ -24,30 +100,15 @@ def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
player_key, widget_id = self._search_regex(
|
_, video_id, player_key = next(IVXPlayerIE._extract_embed_urls(url, webpage)).split(':')
|
||||||
r'<ivs-player\s*[^>]+data-ivs-key\s*=\s*"(?P<player_key>[\w]+)[^>]+\bdata-ivs-wid="(?P<widget_id>[\w-]+)',
|
|
||||||
webpage, 'player_key, widget_id', group=('player_key', 'widget_id'))
|
|
||||||
|
|
||||||
json_ld_data = self._search_json_ld(webpage, display_id)
|
json_ld_data = self._search_json_ld(webpage, display_id)
|
||||||
|
|
||||||
json_data = self._download_json(
|
return self.url_result(
|
||||||
f'https://ivxplayer.ivideosmart.com/prod/widget/{widget_id}',
|
f'ivxplayer:{video_id}:{player_key}', display_id=display_id,
|
||||||
display_id, query={'key': player_key})
|
thumbnail=self._html_search_meta('twitter:image:src', webpage) or self._og_search_thumbnail(webpage),
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
tags=try_call(lambda: self._html_search_meta('keywords', webpage).split(',')),
|
||||||
json_data['player']['video_url'], display_id, ext='mp4')
|
description=(json_ld_data.get('description')
|
||||||
|
or self._html_search_meta(('description', 'twitter:description'), webpage)
|
||||||
return {
|
or self._og_search_description(webpage)),
|
||||||
'id': str(json_data['ivx']['id']),
|
url_transparent=True)
|
||||||
'display_id': display_id,
|
|
||||||
'formats': formats,
|
|
||||||
'subtitles': subtitles,
|
|
||||||
'title': (self._html_search_meta('twitter:title', webpage) or self._og_search_title(webpage)
|
|
||||||
or traverse_obj(json_data, ('ivx', 'name'))),
|
|
||||||
'duration': int_or_none(traverse_obj(json_data, ('ivx', 'duration'))),
|
|
||||||
'thumbnail': (self._html_search_meta('twitter:image:src', webpage) or self._og_search_thumbnail(webpage)
|
|
||||||
or traverse_obj(json_data, ('ivx', 'thumbnail_url'))),
|
|
||||||
'description': (json_ld_data.get('description') or self._html_search_meta(['description', 'twitter:description'], webpage)
|
|
||||||
or self._og_search_description(webpage)),
|
|
||||||
'timestamp': parse_iso8601(traverse_obj(json_data, ('ivx', 'created_at'))),
|
|
||||||
'tags': str_or_none(self._html_search_meta('keywords', webpage), '').split(','),
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue