Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RinseFM] - Add: Artist episodes playlist #8794

Merged
merged 7 commits into from Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion yt_dlp/extractor/_extractors.py
Expand Up @@ -1590,7 +1590,10 @@
from .reuters import ReutersIE
from .reverbnation import ReverbNationIE
from .rheinmaintv import RheinMainTVIE
from .rinsefm import RinseFMIE
from .rinsefm import (
RinseFMIE,
RinseFMArtistPlaylistIE,
)
from .rmcdecouverte import RMCDecouverteIE
from .rockstargames import RockstarGamesIE
from .rokfin import (
Expand Down
69 changes: 58 additions & 11 deletions yt_dlp/extractor/rinsefm.py
@@ -1,8 +1,24 @@
from .common import InfoExtractor
from ..utils import format_field, parse_iso8601
from ..utils import format_field, parse_iso8601, traverse_obj


class RinseFMIE(InfoExtractor):
class RinseFMBaseIE(InfoExtractor):
@staticmethod
def _parse_entry(entry):
return {
**traverse_obj(entry, {
'id': ('id'),
'title': ('title'),
'url': ('fileUrl'),
'vcode': 'none',
'release_timestamp': ('episodeDate', {parse_iso8601}),
}),
'thumbnail': format_field(
entry, [('featuredImage', 0, 'filename')], 'https://rinse.imgix.net/media/%s', default=None),
}
SirElderling marked this conversation as resolved.
Show resolved Hide resolved


class RinseFMIE(RinseFMBaseIE):
_VALID_URL = r'https?://(?:www\.)?rinse\.fm/episodes/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://rinse.fm/episodes/club-glow-15-12-2023-2000/',
Expand All @@ -22,12 +38,43 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, display_id)
entry = self._search_nextjs_data(webpage, display_id)['props']['pageProps']['entry']

return {
'id': entry['id'],
'title': entry.get('title'),
'url': entry['fileUrl'],
'vcodec': 'none',
'release_timestamp': parse_iso8601(entry.get('episodeDate')),
'thumbnail': format_field(
entry, [('featuredImage', 0, 'filename')], 'https://rinse.imgix.net/media/%s', default=None),
}
return self._parse_entry(entry)


class RinseFMArtistPlaylistIE(RinseFMBaseIE):
_VALID_URL = r'https?://(?:www\.)?rinse\.fm/shows/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://rinse.fm/shows/resources/',
'info_dict': {
'id': 'resources',
'title': '[re]sources',
'description': '[re]sources est un label parisien piloté par le DJ et producteur Tommy Kid.'
},
'playlist_mincount': 40
}, {
'url': 'https://rinse.fm/shows/ivy/',
'info_dict': {
'id': 'ivy',
'title': '[IVY]',
'description': 'A dedicated space for DNB/Turbo House and 4x4.'
},
'playlist_mincount': 7
}]

def _entries(self, episodes):
for episode in episodes:
yield self._parse_entry(episode)
seproDev marked this conversation as resolved.
Show resolved Hide resolved

def _real_extract(self, url):
playlist_id = self._match_id(url)
webpage = self._download_webpage(url, playlist_id)
title = self._og_search_title(webpage) or self._html_search_meta('title', webpage)
description = self._og_search_description(webpage) or self._html_search_meta(
'description', webpage)

episodes = traverse_obj(
self._search_nextjs_data(webpage, playlist_id),
('props', 'pageProps', 'episodes', lambda _, v: v['fileUrl'].endswith('mp3')))
SirElderling marked this conversation as resolved.
Show resolved Hide resolved

return self.playlist_result(
self._entries(episodes), playlist_id, title, description=description)