Skip to content

Commit 9937224

Browse files
committed
EBSCO Discovery Layer: Possible fix for PDF issue
https://forums.zotero.org/discussion/comment/504322/#Comment_504322
1 parent 2e13e94 commit 9937224

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

EBSCO Discovery Layer.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsibv",
12-
"lastUpdated": "2024-02-04 04:24:48"
12+
"lastUpdated": "2025-12-22 18:11:41"
1313
}
1414

1515
/*
@@ -117,9 +117,20 @@ async function scrape(doc, url = doc.location.href) {
117117
let risURL = `/linkprocessor/v2-ris?recordId=${recordId}&opid=${opid}&lang=en`;
118118
// Z.debug(risURL)
119119

120-
// this won't work always
121-
let pdfURL = `/linkprocessor/v2-pdf?recordId=${recordId}&sourceRecordId=${recordId}&profileIdentifier=${opid}&intent=download&lang=en`;
122-
120+
let pdfURL;
121+
try {
122+
let [{ result }] = await requestJSON(`/api/viewer/v6/htmlfulltext/${recordId}?opid=${opid}`);
123+
let { links } = result;
124+
Z.debug('Links:');
125+
Z.debug(links);
126+
let downloadLink = links['v2-downloadLinks']?.find(link => link.type === 'pdf');
127+
if (!downloadLink) downloadLink = links.downloadLinks.find(link => link.type === 'pdf');
128+
pdfURL = downloadLink.url;
129+
}
130+
catch (e) {
131+
Zotero.debug('Error while locating PDF download link: ' + e);
132+
pdfURL = `/linkprocessor/v2-pdf?recordId=${recordId}&sourceRecordId=${recordId}&profileIdentifier=${opid}&intent=download&lang=en`
133+
}
123134

124135
let risText = await requestText(risURL);
125136
// Z.debug(risText)
@@ -143,5 +154,6 @@ async function scrape(doc, url = doc.location.href) {
143154
}
144155

145156
/** BEGIN TEST CASES **/
146-
157+
var testCases = [
158+
]
147159
/** END TEST CASES **/

0 commit comments

Comments
 (0)