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

[extractor/discogs] Add extractor #6624

Merged
merged 5 commits into from Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions yt_dlp/extractor/_extractors.py
Expand Up @@ -499,6 +499,7 @@
DeuxMNewsIE
)
from .digitalconcerthall import DigitalConcertHallIE
from .discogs import DiscogsReleasePlaylistIE
from .discovery import DiscoveryIE
from .disney import DisneyIE
from .dispeak import DigitallySpeakingIE
Expand Down
36 changes: 36 additions & 0 deletions yt_dlp/extractor/discogs.py
@@ -0,0 +1,36 @@
from .common import InfoExtractor
bashonly marked this conversation as resolved.
Show resolved Hide resolved


class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
bashonly marked this conversation as resolved.
Show resolved Hide resolved
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': {
'id': 'release1',
'title': 'Stockholm',
},
'playlist_mincount': 7,
}, {
'url': 'https://www.discogs.com/master/113-Vince-Watson-Moments-In-Time',
'info_dict': {
'id': 'master113',
'title': 'Moments In Time',
},
'playlist_mincount': 53,
}]

def _real_extract(self, url):
mobj = self._match_valid_url(url)
playlist_id, playlist_type = mobj.group('id', 'type')
bashonly marked this conversation as resolved.
Show resolved Hide resolved

api = f'https://api.discogs.com/{playlist_type}s/{playlist_id}'
display_id = f'{playlist_type}{playlist_id}'
response = self._download_json(api, display_id)
bashonly marked this conversation as resolved.
Show resolved Hide resolved

playlist_title = response.get('title')
entries = [
self.url_result(video.get('uri'), video_title=video.get('title'))
for video in response.get('videos')
]

return self.playlist_result(entries, display_id, playlist_title)
bashonly marked this conversation as resolved.
Show resolved Hide resolved