Compare commits

..

2 Commits

Author SHA1 Message Date
Julio Napurí
291b1ce824
Merge b6059b8b9c into b83ca24eb7 2024-11-11 01:04:29 +00:00
Julio Napurí
b6059b8b9c [ie/Spreaker] Fix Spreaker URL detection 2024-11-10 20:04:15 -05:00
2 changed files with 36 additions and 34 deletions

View File

@ -1939,7 +1939,6 @@ from .spotify import (
) )
from .spreaker import ( from .spreaker import (
SpreakerIE, SpreakerIE,
SpreakerPageIE,
SpreakerShowIE, SpreakerShowIE,
SpreakerShowPageIE, SpreakerShowPageIE,
) )

View File

@ -4,11 +4,13 @@ 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):
@ -58,7 +60,8 @@ def _extract_episode(data, episode_id=None):
class SpreakerIE(InfoExtractor): class SpreakerIE(InfoExtractor):
_VALID_URL = r'''(?x) _VALID_URL = [
r'''(?x)
https?:// https?://
api\.spreaker\.com/ api\.spreaker\.com/
(?: (?:
@ -66,8 +69,9 @@ 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': {
@ -92,39 +96,38 @@ 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, key = self._match_valid_url(url).group( episode_id = self._match_id(url)
'id', 'key')
query = {} query = {}
if key is not None: if key := traverse_obj(url, ({parse_qs}, 'key', 0)):
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, episode_id, query=query)['response']['episode']
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 = [{