Skip to content

Commit

Permalink
DOI Content Negotiation: Restore Crossref outage workaround
Browse files Browse the repository at this point in the history
More planned maintenance for Jan 14, 06:00 - 11:00 UTC

https://status.crossref.org/incidents/nfjw3myvh981
  • Loading branch information
dstillman committed Jan 11, 2025
1 parent c84ee62 commit e5b6d98
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion DOI Content Negotiation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 8,
"lastUpdated": "2024-09-27 14:35:38"
"lastUpdated": "2025-01-11 08:07:57"
}

/*
Expand Down Expand Up @@ -64,6 +64,34 @@ async function doSearch(items) {
}

async function processDOI(doi) {
// TEMP: Use Crossref REST for Crossref DOIs during Crossref 2025-01-14 outage
let currentDate = new Date();
let startDate = new Date(Date.UTC(2025, 0, 14, 5, 0, 0)); // Jan 14, 2025, 05:00 UTC (1 hour before outage)
let endDate = new Date(Date.UTC(2025, 0, 14, 13, 0, 0)); // Jan 14, 2025, 13:00 UTC (2 hours after outage)

Check failure on line 70 in DOI Content Negotiation.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Multiple spaces found before '='

if (currentDate >= startDate && currentDate <= endDate) {
try {
let raJSON = await requestJSON(
`https://doi.org/ra/${encodeURIComponent(doi)}`
);
if (raJSON.length) {
let ra = raJSON[0].RA;
if (ra == 'Crossref') {
let translate = Zotero.loadTranslator('search');
// Crossref REST
translate.setTranslator("0a61e167-de9a-4f93-a68a-628b48855909");
let item = { itemType: "journalArticle", DOI: doi };
translate.setSearch(item);
translate.translate();
return;
}
}
}
catch (e) {
Z.debug(e);
}
}

let response = await requestText(
`https://doi.org/${encodeURIComponent(doi)}`,
{ headers: { Accept: "application/vnd.datacite.datacite+json, application/vnd.crossref.unixref+xml, application/vnd.citationstyles.csl+json" } }
Expand Down

0 comments on commit e5b6d98

Please sign in to comment.