mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 01:31:25 +01:00
Compare commits
7 Commits
3df2aae863
...
dc22c4cc96
Author | SHA1 | Date | |
---|---|---|---|
|
dc22c4cc96 | ||
|
be3579aaf0 | ||
|
85fdc66b6e | ||
|
8cbf4659bd | ||
|
0bfcbc79b6 | ||
|
d07eb72f6f | ||
|
734d7bd4a3 |
|
@ -708,6 +708,7 @@ from .gab import (
|
||||||
GabTVIE,
|
GabTVIE,
|
||||||
)
|
)
|
||||||
from .gaia import GaiaIE
|
from .gaia import GaiaIE
|
||||||
|
from .gamedevtv import GameDevTVDashboardIE
|
||||||
from .gamejolt import (
|
from .gamejolt import (
|
||||||
GameJoltCommunityIE,
|
GameJoltCommunityIE,
|
||||||
GameJoltGameIE,
|
GameJoltGameIE,
|
||||||
|
|
|
@ -1362,7 +1362,7 @@ class AdobePassIE(InfoExtractor): # XXX: Conventionally, base classes should en
|
||||||
|
|
||||||
def _download_webpage_handle(self, *args, **kwargs):
|
def _download_webpage_handle(self, *args, **kwargs):
|
||||||
headers = self.geo_verification_headers()
|
headers = self.geo_verification_headers()
|
||||||
headers.update(kwargs.get('headers', {}))
|
headers.update(kwargs.get('headers') or {})
|
||||||
kwargs['headers'] = headers
|
kwargs['headers'] = headers
|
||||||
return super()._download_webpage_handle(
|
return super()._download_webpage_handle(
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
|
|
|
@ -7,17 +7,19 @@ from ..networking.exceptions import HTTPError
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
join_nonempty,
|
||||||
parse_age_limit,
|
parse_age_limit,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
try_get,
|
try_get,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
|
urljoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class FOXIE(InfoExtractor):
|
class FOXIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?fox(?:sports)?\.com/(?:watch|replay)/(?P<id>[\da-fA-F]+)'
|
_VALID_URL = r'https?://(?:www\.)?fox(?:sports)?\.com/(?:watch|replay)/(?!play-)(?P<id>[\w-]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# clip
|
# clip
|
||||||
'url': 'https://www.fox.com/watch/4b765a60490325103ea69888fb2bd4e8/',
|
'url': 'https://www.fox.com/watch/4b765a60490325103ea69888fb2bd4e8/',
|
||||||
|
@ -30,8 +32,9 @@ class FOXIE(InfoExtractor):
|
||||||
'duration': 102,
|
'duration': 102,
|
||||||
'timestamp': 1504291893,
|
'timestamp': 1504291893,
|
||||||
'upload_date': '20170901',
|
'upload_date': '20170901',
|
||||||
'creator': 'FOX',
|
'creators': ['FOX'],
|
||||||
'series': 'Gotham',
|
# actual series name 'Gotham' is no longer returned by the API
|
||||||
|
'series': 'Aftermath: Bruce Wayne Develops Into The Dark Knight',
|
||||||
'age_limit': 14,
|
'age_limit': 14,
|
||||||
'episode': 'Aftermath: Bruce Wayne Develops Into The Dark Knight',
|
'episode': 'Aftermath: Bruce Wayne Develops Into The Dark Knight',
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
|
@ -39,6 +42,24 @@ class FOXIE(InfoExtractor):
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
# XML endpoint
|
||||||
|
'url': 'https://www.foxsports.com/watch/fmc-m2du80v5ewz11pbw',
|
||||||
|
'md5': '5451a633a5ca87b582a4d025df6852e6',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'fmc-m2du80v5ewz11pbw',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'WWE FRIDAY NIGHT SMACKDOWN',
|
||||||
|
'description': 'From Fiserv Forum in Milwaukee, WI',
|
||||||
|
'duration': 5367,
|
||||||
|
'timestamp': 1698176671,
|
||||||
|
'upload_date': '20231024',
|
||||||
|
'creators': ['fox-digital'],
|
||||||
|
'series': 'WWE FRIDAY NIGHT SMACKDOWN',
|
||||||
|
'age_limit': 0,
|
||||||
|
'episode': 'WWE FRIDAY NIGHT SMACKDOWN',
|
||||||
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
# episode, geo-restricted
|
# episode, geo-restricted
|
||||||
'url': 'https://www.fox.com/watch/087036ca7f33c8eb79b08152b4dd75c1/',
|
'url': 'https://www.fox.com/watch/087036ca7f33c8eb79b08152b4dd75c1/',
|
||||||
|
@ -54,9 +75,13 @@ class FOXIE(InfoExtractor):
|
||||||
}]
|
}]
|
||||||
_GEO_BYPASS = False
|
_GEO_BYPASS = False
|
||||||
_HOME_PAGE_URL = 'https://www.fox.com/'
|
_HOME_PAGE_URL = 'https://www.fox.com/'
|
||||||
_API_KEY = '6E9S4bmcoNnZwVLOHywOv8PJEdu76cM9'
|
_API_KEY = '6E9S4bmcoNnZwVLOHywOv8PJEdu76cM9' # sports: 'cf289e299efdfa39fb6316f259d1de93'
|
||||||
_access_token = None
|
_access_token = None
|
||||||
_device_id = str(uuid.uuid4())
|
_device_id = str(uuid.uuid4())
|
||||||
|
_XML_NS = {
|
||||||
|
'vmap': 'http://www.iab.net/videosuite/vmap',
|
||||||
|
'yospacenet': 'http://www.yospace.com/extension',
|
||||||
|
}
|
||||||
|
|
||||||
def _call_api(self, path, video_id, data=None):
|
def _call_api(self, path, video_id, data=None):
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -66,7 +91,7 @@ class FOXIE(InfoExtractor):
|
||||||
headers['Authorization'] = 'Bearer ' + self._access_token
|
headers['Authorization'] = 'Bearer ' + self._access_token
|
||||||
try:
|
try:
|
||||||
return self._download_json(
|
return self._download_json(
|
||||||
'https://api3.fox.com/v2.0/' + path,
|
urljoin('https://api3.fox.com/v2.0/', path),
|
||||||
video_id, data=data, headers=headers)
|
video_id, data=data, headers=headers)
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, HTTPError) and e.cause.status == 403:
|
if isinstance(e.cause, HTTPError) and e.cause.status == 403:
|
||||||
|
@ -100,8 +125,8 @@ class FOXIE(InfoExtractor):
|
||||||
f'previewpassmvpd?device_id={self._device_id}&mvpd_id=TempPass_fbcfox_60min',
|
f'previewpassmvpd?device_id={self._device_id}&mvpd_id=TempPass_fbcfox_60min',
|
||||||
video_id)['accessToken']
|
video_id)['accessToken']
|
||||||
|
|
||||||
video = self._call_api('watch', video_id, data=json.dumps({
|
video = self._call_api('https://prod.api.video.fox/v2.0/watch', video_id, data=json.dumps({
|
||||||
'capabilities': ['drm/widevine', 'fsdk/yo'],
|
'capabilities': ['fsdk/yo/v3'],
|
||||||
'deviceWidth': 1280,
|
'deviceWidth': 1280,
|
||||||
'deviceHeight': 720,
|
'deviceHeight': 720,
|
||||||
'maxRes': '720p',
|
'maxRes': '720p',
|
||||||
|
@ -116,13 +141,16 @@ class FOXIE(InfoExtractor):
|
||||||
'privacy': {'us': '1---'},
|
'privacy': {'us': '1---'},
|
||||||
'siteSection': '',
|
'siteSection': '',
|
||||||
'streamType': 'vod',
|
'streamType': 'vod',
|
||||||
'streamId': video_id}).encode())
|
'streamId': video_id,
|
||||||
|
}).encode())
|
||||||
title = video['name']
|
|
||||||
release_url = video['url']
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
m3u8_url = self._download_json(release_url, video_id)['playURL']
|
if playback_url := traverse_obj(video, ('playbackUrl', {url_or_none})):
|
||||||
|
xml_data = self._download_xml(playback_url, video_id)
|
||||||
|
stream = xml_data.find('vmap:Extensions/vmap:Extension/yospacenet:Stream', self._XML_NS)
|
||||||
|
m3u8_url = join_nonempty('https://', stream.get('urlDomain'), stream.get('urlSuffix'), delim='')
|
||||||
|
else:
|
||||||
|
m3u8_url = self._download_json(video['url'], video_id)['playURL']
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, HTTPError) and e.cause.status == 403:
|
if isinstance(e.cause, HTTPError) and e.cause.status == 403:
|
||||||
error = self._parse_json(e.cause.response.read().decode(), video_id)
|
error = self._parse_json(e.cause.response.read().decode(), video_id)
|
||||||
|
@ -130,9 +158,11 @@ class FOXIE(InfoExtractor):
|
||||||
self.raise_geo_restricted(countries=['US'])
|
self.raise_geo_restricted(countries=['US'])
|
||||||
raise ExtractorError(error['description'], expected=True)
|
raise ExtractorError(error['description'], expected=True)
|
||||||
raise
|
raise
|
||||||
formats = self._extract_m3u8_formats(
|
|
||||||
m3u8_url, video_id, 'mp4',
|
if not m3u8_url or m3u8_url == 'https://':
|
||||||
entry_protocol='m3u8_native', m3u8_id='hls')
|
raise ExtractorError('Unable to extract m3u8 url')
|
||||||
|
|
||||||
|
formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', m3u8_id='hls')
|
||||||
|
|
||||||
data = try_get(
|
data = try_get(
|
||||||
video, lambda x: x['trackingData']['properties'], dict) or {}
|
video, lambda x: x['trackingData']['properties'], dict) or {}
|
||||||
|
@ -157,7 +187,7 @@ class FOXIE(InfoExtractor):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': video.get('name'),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'description': video.get('description'),
|
'description': video.get('description'),
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
|
|
|
@ -5,7 +5,7 @@ from ..utils import float_or_none, make_archive_id, smuggle_url
|
||||||
|
|
||||||
|
|
||||||
class FoxSportsIE(InfoExtractor):
|
class FoxSportsIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?foxsports\.com/watch/(?P<id>[\w-]+)'
|
_VALID_URL = r'https?://(?:www\.)?foxsports\.com/watch/(?P<id>play-[\w-]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.foxsports.com/watch/play-612168c6700004b',
|
'url': 'https://www.foxsports.com/watch/play-612168c6700004b',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
|
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