mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 01:31:25 +01:00
Compare commits
4 Commits
83e25e0d01
...
420769e1b0
Author | SHA1 | Date | |
---|---|---|---|
|
420769e1b0 | ||
|
be3579aaf0 | ||
|
85fdc66b6e | ||
|
f2767e2ce0 |
|
@ -376,6 +376,7 @@ from .chaturbate import ChaturbateIE
|
|||
from .chilloutzone import ChilloutzoneIE
|
||||
from .chzzk import (
|
||||
CHZZKLiveIE,
|
||||
CHZZKChannelIE,
|
||||
CHZZKVideoIE,
|
||||
)
|
||||
from .cinemax import CinemaxIE
|
||||
|
@ -708,6 +709,7 @@ from .gab import (
|
|||
GabTVIE,
|
||||
)
|
||||
from .gaia import GaiaIE
|
||||
from .gamedevtv import GameDevTVDashboardIE
|
||||
from .gamejolt import (
|
||||
GameJoltCommunityIE,
|
||||
GameJoltGameIE,
|
||||
|
|
|
@ -1362,7 +1362,7 @@ class AdobePassIE(InfoExtractor): # XXX: Conventionally, base classes should en
|
|||
|
||||
def _download_webpage_handle(self, *args, **kwargs):
|
||||
headers = self.geo_verification_headers()
|
||||
headers.update(kwargs.get('headers', {}))
|
||||
headers.update(kwargs.get('headers') or {})
|
||||
kwargs['headers'] = headers
|
||||
return super()._download_webpage_handle(
|
||||
*args, **kwargs)
|
||||
|
|
|
@ -85,6 +85,91 @@ class CHZZKLiveIE(InfoExtractor):
|
|||
}
|
||||
|
||||
|
||||
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+)'
|
||||
|
|
141
yt_dlp/extractor/gamedevtv.py
Normal file
141
yt_dlp/extractor/gamedevtv.py
Normal file
|
@ -0,0 +1,141 @@
|
|||
import json
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..networking.exceptions import HTTPError
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
clean_html,
|
||||
int_or_none,
|
||||
join_nonempty,
|
||||
parse_iso8601,
|
||||
str_or_none,
|
||||
url_or_none,
|
||||
)
|
||||
from ..utils.traversal import traverse_obj
|
||||
|
||||
|
||||
class GameDevTVDashboardIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?gamedev\.tv/dashboard/courses/(?P<course_id>\d+)(?:/(?P<lecture_id>\d+))?'
|
||||
_NETRC_MACHINE = 'gamedevtv'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.gamedev.tv/dashboard/courses/25',
|
||||
'info_dict': {
|
||||
'id': '25',
|
||||
'title': 'Complete Blender Creator 3: Learn 3D Modelling for Beginners',
|
||||
'tags': ['blender', 'course', 'all', 'box modelling', 'sculpting'],
|
||||
'categories': ['Blender', '3D Art'],
|
||||
'thumbnail': 'https://gamedev-files.b-cdn.net/courses/qisc9pmu1jdc.jpg',
|
||||
'upload_date': '20220516',
|
||||
'timestamp': 1652694420,
|
||||
'modified_date': '20241027',
|
||||
'modified_timestamp': 1730049658,
|
||||
},
|
||||
'playlist_count': 100,
|
||||
}, {
|
||||
'url': 'https://www.gamedev.tv/dashboard/courses/63/2279',
|
||||
'info_dict': {
|
||||
'id': 'df04f4d8-68a4-4756-a71b-9ca9446c3a01',
|
||||
'ext': 'mp4',
|
||||
'modified_timestamp': 1701695752,
|
||||
'upload_date': '20230504',
|
||||
'episode': 'MagicaVoxel Community Course Introduction',
|
||||
'series_id': '63',
|
||||
'title': 'MagicaVoxel Community Course Introduction',
|
||||
'timestamp': 1683195397,
|
||||
'modified_date': '20231204',
|
||||
'categories': ['3D Art', 'MagicaVoxel'],
|
||||
'season': 'MagicaVoxel Community Course',
|
||||
'tags': ['MagicaVoxel', 'all', 'course'],
|
||||
'series': 'MagicaVoxel 3D Art Mini Course',
|
||||
'duration': 1405,
|
||||
'episode_number': 1,
|
||||
'season_number': 1,
|
||||
'season_id': '219',
|
||||
'description': 'md5:a378738c5bbec1c785d76c067652d650',
|
||||
'display_id': '63-219-2279',
|
||||
'alt_title': '1_CC_MVX MagicaVoxel Community Course Introduction.mp4',
|
||||
'thumbnail': 'https://vz-23691c65-6fa.b-cdn.net/df04f4d8-68a4-4756-a71b-9ca9446c3a01/thumbnail.jpg',
|
||||
},
|
||||
}]
|
||||
_API_HEADERS = {}
|
||||
|
||||
def _perform_login(self, username, password):
|
||||
try:
|
||||
response = self._download_json(
|
||||
'https://api.gamedev.tv/api/students/login', None, 'Logging in',
|
||||
headers={'Content-Type': 'application/json'},
|
||||
data=json.dumps({
|
||||
'email': username,
|
||||
'password': password,
|
||||
'cart_items': [],
|
||||
}).encode())
|
||||
except ExtractorError as e:
|
||||
if isinstance(e.cause, HTTPError) and e.cause.status == 401:
|
||||
raise ExtractorError('Invalid username/password', expected=True)
|
||||
raise
|
||||
|
||||
self._API_HEADERS['Authorization'] = f'{response["token_type"]} {response["access_token"]}'
|
||||
|
||||
def _real_initialize(self):
|
||||
if not self._API_HEADERS.get('Authorization'):
|
||||
self.raise_login_required(
|
||||
'This content is only available with purchase', method='password')
|
||||
|
||||
def _entries(self, data, course_id, course_info, selected_lecture):
|
||||
for section in traverse_obj(data, ('sections', ..., {dict})):
|
||||
section_info = traverse_obj(section, {
|
||||
'season_id': ('id', {str_or_none}),
|
||||
'season': ('title', {str}),
|
||||
'season_number': ('order', {int_or_none}),
|
||||
})
|
||||
for lecture in traverse_obj(section, ('lectures', lambda _, v: url_or_none(v['video']['playListUrl']))):
|
||||
if selected_lecture and str(lecture.get('id')) != selected_lecture:
|
||||
continue
|
||||
display_id = join_nonempty(course_id, section_info.get('season_id'), lecture.get('id'))
|
||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||
lecture['video']['playListUrl'], display_id, 'mp4', m3u8_id='hls')
|
||||
yield {
|
||||
**course_info,
|
||||
**section_info,
|
||||
'id': display_id, # fallback
|
||||
'display_id': display_id,
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
'series': course_info.get('title'),
|
||||
'series_id': course_id,
|
||||
**traverse_obj(lecture, {
|
||||
'id': ('video', 'guid', {str}),
|
||||
'title': ('title', {str}),
|
||||
'alt_title': ('video', 'title', {str}),
|
||||
'description': ('description', {clean_html}),
|
||||
'episode': ('title', {str}),
|
||||
'episode_number': ('order', {int_or_none}),
|
||||
'duration': ('video', 'duration_in_sec', {int_or_none}),
|
||||
'timestamp': ('video', 'created_at', {parse_iso8601}),
|
||||
'modified_timestamp': ('video', 'updated_at', {parse_iso8601}),
|
||||
'thumbnail': ('video', 'thumbnailUrl', {url_or_none}),
|
||||
}),
|
||||
}
|
||||
|
||||
def _real_extract(self, url):
|
||||
course_id, lecture_id = self._match_valid_url(url).group('course_id', 'lecture_id')
|
||||
data = self._download_json(
|
||||
f'https://api.gamedev.tv/api/courses/my/{course_id}', course_id,
|
||||
headers=self._API_HEADERS)['data']
|
||||
|
||||
course_info = traverse_obj(data, {
|
||||
'title': ('title', {str}),
|
||||
'tags': ('tags', ..., 'name', {str}),
|
||||
'categories': ('categories', ..., 'title', {str}),
|
||||
'timestamp': ('created_at', {parse_iso8601}),
|
||||
'modified_timestamp': ('updated_at', {parse_iso8601}),
|
||||
'thumbnail': ('image', {url_or_none}),
|
||||
})
|
||||
|
||||
entries = self._entries(data, course_id, course_info, lecture_id)
|
||||
if lecture_id:
|
||||
lecture = next(entries, None)
|
||||
if not lecture:
|
||||
raise ExtractorError('Lecture not found')
|
||||
return lecture
|
||||
return self.playlist_result(entries, course_id, **course_info)
|
Loading…
Reference in New Issue
Block a user