Compare commits

...

3 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
Julio Napurí
b10c245a82 [ie/Spreaker] fix SpreakerPageIE URL detection 2024-11-10 16:50:22 -05:00
2 changed files with 37 additions and 50 deletions

View File

@ -1938,9 +1938,7 @@ from .spotify import (
SpotifyShowIE,
)
from .spreaker import (
SpreakerEpisodeIE,
SpreakerIE,
SpreakerPageIE,
SpreakerShowIE,
SpreakerShowPageIE,
)

View File

@ -4,11 +4,13 @@ from .common import InfoExtractor
from ..utils import (
float_or_none,
int_or_none,
parse_qs,
str_or_none,
try_get,
unified_timestamp,
url_or_none,
)
from ..utils.traversal import traverse_obj
def _extract_episode(data, episode_id=None):
@ -58,15 +60,18 @@ def _extract_episode(data, episode_id=None):
class SpreakerIE(InfoExtractor):
_VALID_URL = r'''(?x)
https?://
api\.spreaker\.com/
(?:
(?:download/)?episode|
v2/episodes
)/
(?P<id>\d+)
'''
_VALID_URL = [
r'''(?x)
https?://
api\.spreaker\.com/
(?:
(?:download/)?episode|
v2/episodes
)/
(?P<id>\d+)
''',
r'https?://(?:www\.)?spreaker\.com/episode/[^#?/]*?(?P<id>\d+)/?(?:[?#]|$)',
]
_TESTS = [{
'url': 'https://api.spreaker.com/episode/12534508',
'info_dict': {
@ -91,34 +96,38 @@ class SpreakerIE(InfoExtractor):
}, {
'url': 'https://api.spreaker.com/v2/episodes/12534508?export=episode_segments',
'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):
episode_id = self._match_id(url)
query = {}
if key := traverse_obj(url, ({parse_qs}, 'key', 0)):
query = {'key': key}
data = self._download_json(
f'https://api.spreaker.com/v2/episodes/{episode_id}',
episode_id)['response']['episode']
episode_id, query=query)['response']['episode']
return _extract_episode(data, episode_id)
class SpreakerPageIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?spreaker\.com/user/[^/]+/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.spreaker.com/user/9780658/swm-ep15-how-to-market-your-music-part-2',
'only_matching': True,
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
episode_id = self._search_regex(
(r'data-episode_id=["\'](?P<id>\d+)',
r'episode_id\s*:\s*(?P<id>\d+)'), webpage, 'episode id')
return self.url_result(
f'https://api.spreaker.com/episode/{episode_id}',
ie=SpreakerIE.ie_key(), video_id=episode_id)
class SpreakerShowIE(InfoExtractor):
_VALID_URL = r'https?://api\.spreaker\.com/show/(?P<id>\d+)'
_TESTS = [{
@ -170,23 +179,3 @@ class SpreakerShowPageIE(InfoExtractor):
return self.url_result(
f'https://api.spreaker.com/show/{show_id}',
ie=SpreakerShowIE.ie_key(), video_id=show_id)
class SpreakerEpisodeIE(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')
result = f'https://api.spreaker.com/episode/{episode_id}'
if key is not None:
access_key = f'?key={key}'
result = f'https://api.spreaker.com/episode/{episode_id}{access_key}'
data = self._download_json(
result,
episode_id)['response']['episode']
return _extract_episode(data, episode_id)