1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2024-06-29 05:54:33 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Dong Heon Hee
c7780f0058
Merge f2767e2ce0 into f3411af12e 2024-06-26 13:38:48 +03:00
megumin
f3411af12e
[ie/matchtv] Fix extractor (#10190)
Authored by: megumintyan
2024-06-25 00:49:09 +02:00
hui1601
f2767e2ce0
[ie/CHZZK] Support download channel videos 2024-02-14 23:31:29 +09:00
3 changed files with 98 additions and 28 deletions

View File

@ -370,6 +370,7 @@
from .chilloutzone import ChilloutzoneIE
from .chzzk import (
CHZZKLiveIE,
CHZZKChannelIE,
CHZZKVideoIE,
)
from .cinemax import CinemaxIE

View File

@ -87,6 +87,91 @@ def _real_extract(self, url):
}
def _make_vod_result(data):
assert isinstance(data, dict)
if not data.get('videoId'):
return
return {
'_type': 'url_transparent',
'id': data.get('videoId'),
'title': data.get('videoTitle'),
'url': f'https://chzzk.naver.com/video/{data.get("videoNo")}',
'thumbnail': data.get('thumbnailImageUrl'),
'timestamp': data.get('publishDateAt'),
'view_count': data.get('readCount'),
'duration': data.get('duration'),
'age_limit': 19 if data.get('adult') else 0,
'was_live': True if data.get('videoType') == 'REPLAY' else False,
}
class CHZZKChannelIE(InfoExtractor):
IE_NAME = 'chzzk:channel'
_VALID_URL = r'https?://chzzk\.naver\.com/(?P<id>[\da-f]{32})'
_TESTS = [{
'note': 'Both video and replay included',
'url': 'https://chzzk.naver.com/68f895c59a1043bc5019b5e08c83a5c5',
'info_dict': {
'id': '68f895c59a1043bc5019b5e08c83a5c5',
'channel_id': '68f895c59a1043bc5019b5e08c83a5c5',
'description': '나는 머찐 라디유 나는 머찐 라디유' * 26 + '나는 라디유',
'channel': '라디유radiyu',
'title': '라디유radiyu',
'channel_is_verified': False,
},
'playlist_mincount': 4,
}, {
'note': 'Video list paging',
'url': 'https://chzzk.naver.com/2d4aa2f79b0a397d032c479ef1b37a67',
'info_dict': {
'id': '2d4aa2f79b0a397d032c479ef1b37a67',
'channel_id': '2d4aa2f79b0a397d032c479ef1b37a67',
'description': '',
'channel': '진짜후추',
'title': '진짜후추',
'channel_is_verified': False,
},
'playlist_mincount': 86,
}]
def _real_extract(self, url):
channel_id = self._match_id(url)
# even if channel got banned, the video list is still available. but downloading videos leads to error
channel_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v1/channels/{channel_id}', channel_id,
note='Downloading channel info', errnote='Unable to download channel info')
if channel_meta.get('code') != 200:
raise ExtractorError('The channel is not available: %s(%s)' % (
channel_meta.get("message"), channel_meta.get("code")), expected=True)
channel_meta = channel_meta.get('content')
if not channel_meta or not channel_meta.get('channelId'):
raise ExtractorError('The channel does not exist', expected=True)
total_count = 0
videos = []
current_count = 0
while current_count <= total_count:
videos_page = self._download_json(
f'https://api.chzzk.naver.com/service/v1/channels/{channel_id}/videos', channel_meta['channelName'],
query={'sortType': 'LATEST', 'pagingType': 'PAGE', 'size': 18, 'videoType': '', 'page': current_count},
note='Downloading videos page(%s/%s)' % (current_count + 1, total_count + 1), errnote='Unable to download videos page')
if videos_page.get('code') != 200:
raise ExtractorError('Unable to download videos page: %s(%s){videos_page.get("message")}' % (
videos_page.get("message"), videos_page.get("code")), expected=True)
videos_page = videos_page['content']
videos.extend(map(_make_vod_result, videos_page['data']))
total_count = videos_page['totalPages']
current_count += 1
if len(videos) != total_count:
self.to_screen('Warning: The total count of videos is not equal to the actual count: %s != %s' % (len(videos), total_count))
return self.playlist_result(
videos, channel_id, channel_meta['channelName'], channel_meta['channelDescription'],
channel=channel_meta['channelName'], channel_id=channel_id, channel_is_verified=channel_meta['verifiedMark'],
)
class CHZZKVideoIE(InfoExtractor):
IE_NAME = 'chzzk:video'
_VALID_URL = r'https?://chzzk\.naver\.com/video/(?P<id>\d+)'

View File

@ -1,51 +1,35 @@
import random
from .common import InfoExtractor
from ..utils import xpath_text
class MatchTVIE(InfoExtractor):
_VALID_URL = r'https?://matchtv\.ru(?:/on-air|/?#live-player)'
_VALID_URL = [
r'https?://matchtv\.ru/on-air/?(?:$|[?#])',
r'https?://video\.matchtv\.ru/iframe/channel/106/?(?:$|[?#])',
]
_TESTS = [{
'url': 'http://matchtv.ru/#live-player',
'url': 'http://matchtv.ru/on-air/',
'info_dict': {
'id': 'matchtv-live',
'ext': 'flv',
'ext': 'mp4',
'title': r're:^Матч ТВ - Прямой эфир \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
'is_live': True,
'live_status': 'is_live',
},
'params': {
'skip_download': True,
},
}, {
'url': 'http://matchtv.ru/on-air/',
'url': 'https://video.matchtv.ru/iframe/channel/106',
'only_matching': True,
}]
def _real_extract(self, url):
video_id = 'matchtv-live'
video_url = self._download_json(
'http://player.matchtv.ntvplus.tv/player/smil', video_id,
query={
'ts': '',
'quality': 'SD',
'contentId': '561d2c0df7159b37178b4567',
'sign': '',
'includeHighlights': '0',
'userId': '',
'sessionId': random.randint(1, 1000000000),
'contentType': 'channel',
'timeShift': '0',
'platform': 'portal',
},
headers={
'Referer': 'http://player.matchtv.ntvplus.tv/embed-player/NTVEmbedPlayer.swf',
})['data']['videoUrl']
f4m_url = xpath_text(self._download_xml(video_url, video_id), './to')
formats = self._extract_f4m_formats(f4m_url, video_id)
webpage = self._download_webpage('https://video.matchtv.ru/iframe/channel/106', video_id)
video_url = self._html_search_regex(
r'data-config="config=(https?://[^?"]+)[?"]', webpage, 'video URL').replace('/feed/', '/media/') + '.m3u8'
return {
'id': video_id,
'title': 'Матч ТВ - Прямой эфир',
'is_live': True,
'formats': formats,
'formats': self._extract_m3u8_formats(video_url, video_id, 'mp4', live=True),
}