Skip to content

Commit 09f47b5

Browse files
Update Discogs translator detection
1 parent f084232 commit 09f47b5

1 file changed

Lines changed: 10 additions & 28 deletions

File tree

Discogs.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,16 @@
22
"translatorID": "669bb7bd-bc34-46cd-9340-cf8af8187063",
33
"label": "Discogs",
44
"creator": "Michael Z Freeman",
5-
"target": "^https://www\\.discogs\\.com/release/[a-z0-9-]+",
5+
"target": "^https?://www\\.discogs\\.com(?:/[a-z]{2}(?:_[A-Z]{2})?)?/release/\\d+(?:-[^/?#]+)?(?:[/?#]|$)",
66
"minVersion": "5.0",
77
"maxVersion": "",
88
"priority": 100,
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsibv",
12-
"lastUpdated": "2025-11-29 12:24:52"
12+
"lastUpdated": "2026-07-26 08:30:13"
1313
}
1414

15-
/*
16-
HISTORY
17-
18-
This translator was something I've been circling arund for 3 years. I started a BA(Hons) in Creative Music Technology at Falmouth University.
19-
I became frustrated with the lack of citation tools for music releases and audio recordings in general. Zotero does detect the Discogs page as an
20-
audio recording but does not fill in the correct details. Other citation tools out there fail to have searches for music releases and seem to have
21-
no idea that vinyl records can in fact be cited and referenced. All this when as a DJ I am researching releases and writing assessments and dissertations !
22-
So I hope this translator can improve the situation.
23-
24-
METHOD
25-
26-
This translator accesses the "ld+json" block in the "release" Discogs page. It is not designed to use the "master" page for a release as that will not
27-
list the record label.
28-
29-
INFO
30-
31-
Some comments in the code below are based on page https://www.discogs.com/release/126504-Micro-Vicious-Vic-Electric-Impact-The-Mixes
32-
*/
33-
34-
3515
/*
3616
***** BEGIN LICENSE BLOCK *****
3717
@@ -56,7 +36,10 @@ Some comments in the code below are based on page https://www.discogs.com/releas
5636
*/
5737

5838
function detectWeb(doc, url) {
59-
if (url.match(/release\/\d+/)) {
39+
if (
40+
/^https?:\/\/www\.discogs\.com(?:\/[a-z]{2}(?:_[A-Z]{2})?)?\/release\/\d+(?:-[^/?#]+)?(?:[/?#]|$)/.test(url)
41+
&& doc.querySelector('script[type="application/ld+json"]#release_schema')
42+
) {
6043
return "audioRecording";
6144
}
6245
return false;
@@ -66,8 +49,7 @@ function doWeb(doc, url) {
6649
// Create a new Zotero item of type "audioRecording"
6750
let item = new Zotero.Item("audioRecording");
6851

69-
// Locate the JSON-LD script tag
70-
let jsonLdScript = doc.querySelector('script[type="application/ld+json"]');
52+
let jsonLdScript = doc.querySelector('script[type="application/ld+json"]#release_schema');
7153
if (!jsonLdScript) {
7254
Zotero.debug("No JSON-LD found on the page.");
7355
return;
@@ -95,7 +77,7 @@ function doWeb(doc, url) {
9577
}
9678

9779
if (jsonLd.musicReleaseFormat) {
98-
item.medium = jsonLd.musicReleaseFormat; // e.g., "Vinyl"
80+
item.audioRecordingFormat = jsonLd.musicReleaseFormat; // e.g., "Vinyl"
9981
}
10082

10183
if (jsonLd.datePublished) {
@@ -127,10 +109,10 @@ function doWeb(doc, url) {
127109
});
128110
}
129111

130-
// Add the release page URL
112+
item.libraryCatalog = "Discogs";
113+
131114
item.url = url;
132115

133-
// Complete the item and save it to Zotero
134116
item.complete();
135117
}
136118

0 commit comments

Comments
 (0)