Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/yt-dlp/yt-dlp into ytdlp
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/yt-dlp/yt-dlp:
  [extractor/kompas] Add extractor (#4562)
  [extractor/vidio] Support embed link (#4564)
  • Loading branch information
Lesmiscore committed Aug 5, 2022
2 parents baefdf3 + d380fc1 commit 94852b0
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 3 deletions.
1 change: 1 addition & 0 deletions yt_dlp/extractor/_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@
from .kickstarter import KickStarterIE
from .kinja import KinjaEmbedIE
from .kinopoisk import KinoPoiskIE
from .kompas import KompasVideoIE
from .konserthusetplay import KonserthusetPlayIE
from .koo import KooIE
from .kth import KTHIE
Expand Down
68 changes: 68 additions & 0 deletions yt_dlp/extractor/kompas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from .common import InfoExtractor
from ..utils import (
clean_html,
float_or_none,
traverse_obj,
try_call,
)

# Video from www.kompas.tv and video.kompas.com seems use jixie player
# see [1] https://jixie.atlassian.net/servicedesk/customer/portal/2/article/1339654214?src=-1456335525,
# [2] https://scripts.jixie.media/jxvideo.3.1.min.js for more info


class KompasVideoIE(InfoExtractor):
_VALID_URL = r'https?://video\.kompas\.com/\w+/(?P<id>\d+)/(?P<slug>[\w-]+)'
_TESTS = [{
'url': 'https://video.kompas.com/watch/164474/kim-jong-un-siap-kirim-nuklir-lawan-as-dan-korsel',
'info_dict': {
'id': '164474',
'ext': 'mp4',
'title': 'Kim Jong Un Siap Kirim Nuklir Lawan AS dan Korsel',
'description': 'md5:262530c4fb7462398235f9a5dba92456',
'uploader_id': '9262bf2590d558736cac4fff7978fcb1',
'display_id': 'kim-jong-un-siap-kirim-nuklir-lawan-as-dan-korsel',
'duration': 85.066667,
'categories': ['news'],
'thumbnail': 'https://video.jixie.media/1001/164474/164474_1280x720.jpg',
'tags': 'count:9',
}
}]

def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).group('id', 'slug')
webpage = self._download_webpage(url, display_id)

json_data = self._download_json(
'https://apidam.jixie.io/api/public/stream', display_id,
query={'metadata': 'full', 'video_id': video_id})['data']

formats, subtitles = [], {}
for stream in json_data['streams']:
if stream.get('type') == 'HLS':
fmt, sub = self._extract_m3u8_formats_and_subtitles(stream.get('url'), display_id, ext='mp4')
formats.extend(fmt)
self._merge_subtitles(sub, target=subtitles)
else:
formats.append({
'url': stream.get('url'),
'width': stream.get('width'),
'height': stream.get('height'),
'ext': 'mp4',
})

self._sort_formats(formats)
return {
'id': video_id,
'display_id': display_id,
'formats': formats,
'subtitles': subtitles,
'title': json_data.get('title') or self._html_search_meta(['og:title', 'twitter:title'], webpage),
'description': (clean_html(traverse_obj(json_data, ('metadata', 'description')))
or self._html_search_meta(['description', 'og:description', 'twitter:description'], webpage)),
'thumbnails': traverse_obj(json_data, ('metadata', 'thumbnails')),
'duration': float_or_none(traverse_obj(json_data, ('metadata', 'duration'))),
'tags': try_call(lambda: json_data['metadata']['keywords'].split(',')),
'categories': try_call(lambda: json_data['metadata']['categories'].split(',')),
'uploader_id': json_data.get('owner_id'),
}
31 changes: 28 additions & 3 deletions yt_dlp/extractor/vidio.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def _call_api(self, url, video_id, note=None):


class VidioIE(VidioBaseIE):
_VALID_URL = r'https?://(?:www\.)?vidio\.com/watch/(?P<id>\d+)-(?P<display_id>[^/?#&]+)'
_VALID_URL = r'https?://(?:www\.)?vidio\.com/(watch|embed)/(?P<id>\d+)-(?P<display_id>[^/?#&]+)'
_TESTS = [{
'url': 'http://www.vidio.com/watch/165683-dj_ambred-booyah-live-2015',
'md5': 'cd2801394afc164e9775db6a140b91fe',
'md5': 'abac81b1a205a8d94c609a473b5ea62a',
'info_dict': {
'id': '165683',
'display_id': 'dj_ambred-booyah-live-2015',
Expand All @@ -89,7 +89,8 @@ class VidioIE(VidioBaseIE):
'view_count': int,
'dislike_count': int,
'comment_count': int,
'tags': 'count:4',
'tags': 'count:3',
'uploader_url': 'https://www.vidio.com/@twelvepictures',
},
}, {
'url': 'https://www.vidio.com/watch/77949-south-korea-test-fires-missile-that-can-strike-all-of-the-north',
Expand All @@ -98,6 +99,30 @@ class VidioIE(VidioBaseIE):
# Premier-exclusive video
'url': 'https://www.vidio.com/watch/1550718-stand-by-me-doraemon',
'only_matching': True
}, {
# embed url from https://enamplus.liputan6.com/read/5033648/video-fakta-temuan-suspek-cacar-monyet-di-jawa-tengah
'url': 'https://www.vidio.com/embed/7115874-fakta-temuan-suspek-cacar-monyet-di-jawa-tengah',
'info_dict': {
'id': '7115874',
'ext': 'mp4',
'channel_id': '40172876',
'comment_count': int,
'uploader_id': 'liputan6',
'view_count': int,
'dislike_count': int,
'upload_date': '20220804',
'uploader': 'Liputan6.com',
'display_id': 'fakta-temuan-suspek-cacar-monyet-di-jawa-tengah',
'channel': 'ENAM PLUS 165',
'timestamp': 1659605520,
'title': 'Fakta Temuan Suspek Cacar Monyet di Jawa Tengah',
'duration': 59,
'like_count': int,
'tags': ['monkeypox indonesia', 'cacar monyet menyebar', 'suspek cacar monyet di indonesia', 'fakta', 'hoax atau bukan?', 'jawa tengah'],
'thumbnail': 'https://thumbor.prod.vidiocdn.com/83PN-_BKm5sS7emLtRxl506MLqQ=/640x360/filters:quality(70)/vidio-web-prod-video/uploads/video/image/7115874/fakta-suspek-cacar-monyet-di-jawa-tengah-24555a.jpg',
'uploader_url': 'https://www.vidio.com/@liputan6',
'description': 'md5:6d595a18d3b19ee378e335a6f288d5ac',
},
}]

def _real_extract(self, url):
Expand Down

0 comments on commit 94852b0

Please sign in to comment.