Skip to content

scihub_tools

Retrieve the PDFs of DOIs via Sci-Hub.

The DOIs are read from a Zotero export in the Better BibTeX JSON format (Export Items... -> Better BibTeX JSON), the PDFs are named by the citation keys of the items.

dois_from_json

dois_from_json(json_path)

Read the DOIs of a Better BibTeX JSON export of Zotero.

Items without a DOI are skipped.

Parameters:

Name Type Description Default
json_path Path

path of the Better BibTeX JSON file.

required

Returns:

Type Description
dict[str, str]

The DOIs by the citation keys of the items.

scihub_pdf_from_doi

scihub_pdf_from_doi(doi, pdf_path, scihub_url=None)

Download the PDF of a DOI.

Parameters:

Name Type Description Default
doi str

DOI of the publication, e.g., 10.1145/3375633.

required
pdf_path Path

path the PDF is written to.

required
scihub_url str | None

Sci-Hub domain to use; by default the best available domain of scidownl, see scidownl domain.update.

None

scihub_pdfs_from_dois

scihub_pdfs_from_dois(dois, pdf_dir, scihub_url=None)

Download the PDFs of DOIs which are not in the directory yet.

Parameters:

Name Type Description Default
dois dict[str, str]

DOIs by the keys the PDFs are named after, <key>.pdf.

required
pdf_dir Path

directory of the PDFs, created if it does not exist.

required
scihub_url str | None

Sci-Hub domain to use, see scihub_pdf_from_doi.

None

Returns:

Type Description
list[str]

The keys for which no PDF exists after the download.

scihub_pdfs

scihub_pdfs(
    zotero_json_path, pdf_dir=None, scihub_url=None
)

Download the missing PDFs of a Better BibTeX JSON export of Zotero.

Parameters:

Name Type Description Default
zotero_json_path Path

path of the Better BibTeX JSON file.

required
pdf_dir Path | None

directory of the PDFs; by default the directory named after the JSON file next to it, i.e., <substance>/ for <substance>.json.

None
scihub_url str | None

Sci-Hub domain to use, see scihub_pdf_from_doi.

None

Returns:

Type Description
list[str]

The citation keys for which no PDF exists after the download.

scihub_pdfs_command

scihub_pdfs_command(argv=None)

Command line interface scihub_pdfs, see scihub_pdfs.

Parameters:

Name Type Description Default
argv Sequence[str] | None

command line arguments, by default sys.argv[1:].

None