Metadata-Version: 2.4
Name: paperchaser
Version: 0.2.0
Summary: A tool for downloading academic paper references
Author-email: semiquant <Jason.Limberis@ucsf.edu>
License: MIT
Project-URL: Homepage, https://www.SemiQuant.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: beautifulsoup4
Requires-Dist: click
Requires-Dist: tabulate
Requires-Dist: PyPDF2
Requires-Dist: pdf-renamer

# PaperChaser

A Python tool for extracting and downloading academic paper references. Supports both single and two-column PDF formats.

## Features

- Extract references from PDF files with support for:
  - Single and two-column layouts
  - Multiple reference formats (numbered, bracketed, author-year)
  - Smart reference section detection
- Download papers using:
  - DOI lookup
  - Title-based search
  - Multiple sources, tried in order: open access (PMC Open Access Subset,
    Unpaywall, arXiv), then the publisher via your own subscription access,
    then Sci-Hub
  - Per-source failure reasons for every paper that could not be fetched
- Automatic PDF renaming with metadata
- Beautiful command-line interface with:
  - Progress bars
  - Colored status indicators
  - Formatted tables
  - Detailed error reporting

## Installation

```bash
pip install paperchaser
```

## Usage

Basic usage:
```bash
# Extract and download references from a PDF
paperchaser path/to/paper.pdf

# Extract references without downloading (debug mode)
paperchaser path/to/paper.pdf --debug

# Specify output directory
paperchaser path/to/paper.pdf -o downloaded_papers

# Force re-download of existing papers
paperchaser path/to/paper.pdf -f

# Download one or more DOIs directly (bare DOI, doi: prefix or doi.org URL)
paperchaser 10.1056/NEJMoa2001017 https://doi.org/10.1038/s41586-020-2012-7

# Download from a text file with one DOI per line (blank lines and # comments ignored)
paperchaser dois.txt
paperchaser --doi-file dois.txt

# Read DOIs from stdin
cat dois.txt | paperchaser -

# Mix inputs freely; duplicates are removed
paperchaser paper.pdf dois.txt -d 10.1126/science.abb3221
```

### Institutional (subscription) access

Requests go out from the machine you run this on, so if your institution
grants access by IP, running on campus or on the VPN is enough: the DOI is
resolved to the publisher's landing page, the full-text PDF link is read off
it, and the PDF is fetched over that same session.

If your library needs a login rather than just an IP, point `--proxy-prefix`
at your proxy. Both EZproxy styles work:

```bash
# URL-prefix style (a {url} placeholder percent-encodes the target)
paperchaser paper.pdf --proxy-prefix 'https://ucsf.idm.oclc.org/login?url='

# Hostname-rewriting style
paperchaser paper.pdf --proxy-prefix '.ucsf.idm.oclc.org'
```

For proxies or publishers that need an authenticated session (OpenAthens,
Shibboleth, Cloudflare-protected sites), export `cookies.txt` from a browser
you are already logged into and pass it; cookies persist across the whole run:

```bash
paperchaser paper.pdf --proxy-prefix '.ucsf.idm.oclc.org' --cookies cookies.txt
```

Use `--no-scihub` to stop at legitimate sources. Publishers that render the
PDF link only via JavaScript, or that sit behind a bot check (ScienceDirect's
`linkinghub.elsevier.com` is the usual one), will still fail; the run reports
which step failed for each paper.

### Open access sources

`--email` is required for the Unpaywall lookup, which rejects calls that do not
carry a real address. Without it that source is skipped and the run says so.

PMC full text comes from the PMC Cloud Service open-data bucket, which covers
the PMC Open Access Subset. PMC's own `/articles/<id>/pdf` URL is not used: it
now answers scripted requests with a CAPTCHA, and the OA Web Service
(`oa.fcgi`) it replaced has been retired.

Advanced options:
```bash
Usage: paperchaser [OPTIONS] [INPUTS]...

Options:
  -d, --doi TEXT             DOI to download (repeatable)
  -i, --doi-file FILE        Text file with one DOI per line (repeatable)
  -o, --output-dir TEXT      Directory to save downloaded papers
  --email TEXT              Your address, required for the Unpaywall lookup
  --proxy-prefix TEXT       Institutional proxy: URL prefix or EZproxy host suffix
  --cookies FILE            Netscape cookies.txt from a logged-in browser
  --scihub/--no-scihub      Fall back to Sci-Hub (default: True)
  -f, --force              Force download even if paper already exists
  --rename/--no-rename     Rename downloaded PDFs using metadata (default: True)
  --debug                  Show debug information without downloading
  --help                   Show this message and exit
```

## Output Format

The tool provides detailed information about the extraction and download process:
- Reference extraction progress
- Found references with numbering
- Download status for each paper
- Color-coded success/failure indicators
- Detailed error messages for failed downloads
