summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/discogs.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
commit2415e66f889f38503b73e8ebc5f43ca342390e5c (patch)
treeac48ab69d1d96bae3d83756134921e0d90593aa5 /yt_dlp/extractor/discogs.py
parentInitial commit. (diff)
downloadyt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.tar.xz
yt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.zip
Adding upstream version 2024.03.10.upstream/2024.03.10
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/discogs.py')
-rw-r--r--yt_dlp/extractor/discogs.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/yt_dlp/extractor/discogs.py b/yt_dlp/extractor/discogs.py
new file mode 100644
index 0000000..048c622
--- /dev/null
+++ b/yt_dlp/extractor/discogs.py
@@ -0,0 +1,35 @@
+from .common import InfoExtractor
+from .youtube import YoutubeIE
+from ..utils import traverse_obj
+
+
+class DiscogsReleasePlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
+ _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):
+ playlist_id, playlist_type = self._match_valid_url(url).group('id', 'type')
+
+ display_id = f'{playlist_type}{playlist_id}'
+ response = self._download_json(
+ f'https://api.discogs.com/{playlist_type}s/{playlist_id}', display_id)
+
+ entries = [
+ self.url_result(video['uri'], YoutubeIE, video_title=video.get('title'))
+ for video in traverse_obj(response, ('videos', lambda _, v: YoutubeIE.suitable(v['uri'])))]
+
+ return self.playlist_result(entries, display_id, response.get('title'))