Skip to content

Commit

Permalink
fix: priority of DOI and ISBN
Browse files Browse the repository at this point in the history
closes: #216
  • Loading branch information
northword committed Aug 31, 2024
1 parent 4640ecb commit b4b588d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix the issue that ISBN has higher priority than DOI when “Update metadata by identifier”. fixes: [#216](https://github.com/northword/zotero-format-metadata/issues/216)

## [1.18.3] - 2024-08-26

### Fixed
Expand Down
10 changes: 9 additions & 1 deletion src/modules/rules/retrive-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@ export default class UpdateMetadata extends RuleBase<UpdateMetadataOption> {
return item;
}

return (await this.translateByItem(item)) ?? item;
return (await this.translateByItem(item)) ?? (await this.getMetadataFromSemanticScholar(item)) ?? item;
}

async translateByItem(item: Zotero.Item): Promise<Zotero.Item | undefined> {
const itemTemp = Zotero.Utilities.Internal.itemToExportFormat(item, false);
ztoolkit.log("itemToExportFormat: ", itemTemp);
// 如果 Item 包含多个标识符,优先使用 DOI
// 因为部分会议论文包含 ISBN 会导致调用优先级更高的 K10plus ISBN 转换器,导致更新为论文集(书籍)
// ref: https://github.com/northword/zotero-format-metadata/issues/216
if (itemTemp.DOI && itemTemp.ISBN) {
delete itemTemp.ISBN;
}

const translate = new Zotero.Translate.Search();
translate.setSearch(itemTemp);
const translators = await translate.getTranslators();
Expand Down

0 comments on commit b4b588d

Please sign in to comment.