mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 01:31:25 +01:00
Compare commits
1 Commits
291b1ce824
...
209e542f27
Author | SHA1 | Date | |
---|---|---|---|
|
209e542f27 |
|
@ -1939,6 +1939,7 @@ from .spotify import (
|
||||||
)
|
)
|
||||||
from .spreaker import (
|
from .spreaker import (
|
||||||
SpreakerIE,
|
SpreakerIE,
|
||||||
|
SpreakerPageIE,
|
||||||
SpreakerShowIE,
|
SpreakerShowIE,
|
||||||
SpreakerShowPageIE,
|
SpreakerShowPageIE,
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,13 +4,11 @@ from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_qs,
|
|
||||||
str_or_none,
|
str_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
|
||||||
|
|
||||||
|
|
||||||
def _extract_episode(data, episode_id=None):
|
def _extract_episode(data, episode_id=None):
|
||||||
|
@ -60,8 +58,7 @@ def _extract_episode(data, episode_id=None):
|
||||||
|
|
||||||
|
|
||||||
class SpreakerIE(InfoExtractor):
|
class SpreakerIE(InfoExtractor):
|
||||||
_VALID_URL = [
|
_VALID_URL = r'''(?x)
|
||||||
r'''(?x)
|
|
||||||
https?://
|
https?://
|
||||||
api\.spreaker\.com/
|
api\.spreaker\.com/
|
||||||
(?:
|
(?:
|
||||||
|
@ -69,9 +66,8 @@ class SpreakerIE(InfoExtractor):
|
||||||
v2/episodes
|
v2/episodes
|
||||||
)/
|
)/
|
||||||
(?P<id>\d+)
|
(?P<id>\d+)
|
||||||
''',
|
(?:\?key=(?P<key>[^&]+))?
|
||||||
r'https?://(?:www\.)?spreaker\.com/episode/[^#?/]*?(?P<id>\d+)/?(?:[?#]|$)',
|
'''
|
||||||
]
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://api.spreaker.com/episode/12534508',
|
'url': 'https://api.spreaker.com/episode/12534508',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -96,38 +92,39 @@ class SpreakerIE(InfoExtractor):
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://api.spreaker.com/v2/episodes/12534508?export=episode_segments',
|
'url': 'https://api.spreaker.com/v2/episodes/12534508?export=episode_segments',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
|
||||||
'note': 'episode',
|
|
||||||
'url': 'https://www.spreaker.com/episode/grunge-music-origins-the-raw-sound-that-defined-a-generation--60269615',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '60269615',
|
|
||||||
'display_id': 'grunge-music-origins-the-raw-sound-that-',
|
|
||||||
'ext': 'mp3',
|
|
||||||
'title': 'Grunge Music Origins - The Raw Sound that Defined a Generation',
|
|
||||||
'description': str,
|
|
||||||
'timestamp': 1717468905,
|
|
||||||
'upload_date': '20170809',
|
|
||||||
'uploader': 'Katie Brown 2',
|
|
||||||
'uploader_id': '17733249',
|
|
||||||
'duration': 1063.42,
|
|
||||||
'view_count': int,
|
|
||||||
'like_count': int,
|
|
||||||
'comment_count': int,
|
|
||||||
'series': '90s Grunge',
|
|
||||||
},
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
episode_id = self._match_id(url)
|
episode_id, key = self._match_valid_url(url).group(
|
||||||
|
'id', 'key')
|
||||||
query = {}
|
query = {}
|
||||||
if key := traverse_obj(url, ({parse_qs}, 'key', 0)):
|
if key is not None:
|
||||||
query = {'key': key}
|
query = {'key': key}
|
||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
f'https://api.spreaker.com/v2/episodes/{episode_id}',
|
f'https://api.spreaker.com/v2/episodes/{episode_id}',
|
||||||
episode_id, query=query)['response']['episode']
|
episode_id,
|
||||||
|
query=query)['response']['episode']
|
||||||
return _extract_episode(data, episode_id)
|
return _extract_episode(data, episode_id)
|
||||||
|
|
||||||
|
|
||||||
|
class SpreakerPageIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'https?://(?:www\.)?spreaker\.com/episode/(?P<title>[^/?#]+)-(?P<id>\d+)(?:\?key=(?P<key>[^&]+))?'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.spreaker.com/episode/ep-15-music-marketing-likes-part-2--12534508',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
episode_id, key = self._match_valid_url(url).group(
|
||||||
|
'id', 'key')
|
||||||
|
url = f'https://api.spreaker.com/episode/{episode_id}'
|
||||||
|
if key is not None:
|
||||||
|
url = f'https://api.spreaker.com/episode/{episode_id}?key={key}'
|
||||||
|
return self.url_result(
|
||||||
|
url,
|
||||||
|
ie=SpreakerIE.ie_key(), video_id=episode_id)
|
||||||
|
|
||||||
|
|
||||||
class SpreakerShowIE(InfoExtractor):
|
class SpreakerShowIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://api\.spreaker\.com/show/(?P<id>\d+)'
|
_VALID_URL = r'https?://api\.spreaker\.com/show/(?P<id>\d+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user