Compare commits

...

7 Commits

Author SHA1 Message Date
marieell
9fa2ea4fd4
Merge ddc7e9a1bb into be3579aaf0 2024-11-09 21:54:32 +05:30
Steve Ovens
be3579aaf0
[ie/GameDevTV] Add extractor (#11368)
Authored by: stratus-ss, bashonly

Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
2024-11-06 21:58:44 +00:00
bashonly
85fdc66b6e
[ie/adobepass] Fix provider requests (#11472)
Fix bug in dcfeea4dd5

Closes #11469
Authored by: bashonly
2024-11-06 21:26:05 +00:00
marieell
ddc7e9a1bb
[ie/ARD] Use traverse_obj
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
2024-08-28 22:58:11 +02:00
marieell
a434c7b7e2
[ie/ARD] Review feedback
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
2024-08-14 23:13:21 +02:00
marieell
75ff02cf4e [ie/ARD] Review feedback
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
2024-08-13 00:16:30 +02:00
marieell
4e17e8eec2 [ie/ARD] Add Audiothek (#5605) 2024-08-06 00:35:14 +02:00
4 changed files with 262 additions and 1 deletions

View File

@ -149,6 +149,7 @@ from .archiveorg import (
from .arcpublishing import ArcPublishingIE
from .ard import (
ARDIE,
ARDAudiothekIE,
ARDBetaMediathekIE,
ARDMediathekCollectionIE,
)
@ -708,6 +709,7 @@ from .gab import (
GabTVIE,
)
from .gaia import GaiaIE
from .gamedevtv import GameDevTVDashboardIE
from .gamejolt import (
GameJoltCommunityIE,
GameJoltGameIE,

View File

@ -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)

View File

@ -1,4 +1,5 @@
import functools
import json
import re
from .common import InfoExtractor
@ -601,3 +602,120 @@ class ARDMediathekCollectionIE(InfoExtractor):
return self.playlist_result(
OnDemandPagedList(fetch_page, self._PAGE_SIZE), full_id, display_id=display_id,
title=page_data.get('title'), description=page_data.get('synopsis'))
class ARDAudiothekIE(InfoExtractor):
IE_NAME = 'ARD:audiothek'
_VALID_URL = r'''(?x)https://
(?:www\.)?ardaudiothek\.de/
(?:player|live|episode|(?P<playlist>sendung|serie|sammlung))/
(?P<display_id>(?(playlist)[^?#]+?|[^?#]+))/
(?P<id>[a-zA-Z0-9]+)
(?(playlist)/(?P<season>\d+)?/?(?:[?#]|$))'''
_TESTS = [{
'url': 'https://www.ardaudiothek.de/sendung/1live-caiman-club/53375276/',
'info_dict': {
'id': '53375276',
'title': '1LIVE Caiman Club',
'description': 'md5:003cff043a41b14cf045b960b89aaa86',
},
'playlist_mincount': 22,
}, {
'url': 'https://www.ardaudiothek.de/episode/1live-caiman-club/caiman-club-s04e04-cash-out/1live/13556081/',
'info_dict': {
'id': '13556081',
'ext': 'mp3',
'upload_date': '20240717',
'duration': 3339,
'title': 'CAIMAN CLUB (S04E04): Cash Out',
'thumbnail': 'https://api.ardmediathek.de/image-service/images/urn:ard:image:d5014b612429c396',
'description': 'md5:8decf7974ed1cbf5a9d2c537940e1c4b',
'display_id': '1live-caiman-club/caiman-club-s04e04-cash-out/1live',
'timestamp': 1721181641,
'series': '1LIVE Caiman Club',
},
}]
_QUERY_PLAYLIST = '''\
show(id: "%s") {
title
description
items {
nodes {
url
episodeNumber
grouping
isPublished
}
}
}'''
_QUERY_ITEM = '''\
item(id: "%s") {
audioList {
href
distributionType
}
show {
title
}
image {
url
}
synopsis
title
duration
startDate
}'''
_GRAPHQL_ENDPOINT = 'https://api.ardaudiothek.de/graphql'
def _graphql_query(self, display_id, query):
return self._download_json(
self._GRAPHQL_ENDPOINT,
display_id,
data=json.dumps({'query': '{' + query + '}'}).encode(),
headers={
'Content-Type': 'application/json',
},
)['data']
def _real_extract(self, url):
video_id, display_id, playlist_type, season_number = self._match_valid_url(url).group(
'id', 'display_id', 'playlist', 'season')
if re.match('^[/-]*$', display_id):
display_id = video_id
if playlist_type:
playlist_info = self.graphql_query(display_id, self._QUERY_PLAYLIST % video_id)['show']
episodes = playlist_info['items']['nodes']
entries = []
for episode in episodes:
if episode['isPublished']:
entries.append(self.url_result(
episode['url'],
ie=ARDAudiothekIE.ie_key()))
return self.playlist_result(entries, video_id, playlist_title=display_id, **traverse_obj(playlist_info, {
'title': ('title', {str}),
'description': ('description', {str}),
}))
return {
'display_id': display_id,
'formats': traverse_obj(self.graphql_query(display_id, self._QUERY_ITEM % video_id), (
'item', 'audioList', lambda _, v: url_or_none(v['href']), {
'url': 'href',
'format_id': ('distributionType', {str}),
})),
'id': video_id,
**traverse_obj(item, {
'description': ('synopsis', {str}),
'duration': ('duration', {int_or_none}),
'series': ('show', 'title'),
'thumbnail': ('image', 'url', {url_or_none}),
'timestamp': ('startDate', {parse_iso8601}),
'title': ('title', {str}),
}),
}

View 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)