Add Scribd PDF Downloader under Scribd/

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Michael-A-SloanandCursor committed 2026-05-15 10:44:57 -04:00
commit 5d2933ea95
28 files changed
+2159

No files matched your search

+224
View File
@@ -0,0 +1,224 @@
# AIDNA — App Installation, Distribution, Notes & Architecture
This document explains how **Scribd PDF Downloader** is put together, how to install it, and how to ship it to other computers.
---
## A — App (what you get)
Three ways to run the same core downloader:
| Mode | Entry point | Best for |
|------|-------------|----------|
| **GUI** | `Start Scribd Downloader.bat` or `Scribd PDF Downloader.exe` | Daily use, preview before download |
| **CLI** | `main.py download <url>` | Automation, scripts, ebooks |
| **Frozen** | Built `.exe` / `.app` in `dist/` | Sharing with people who don’t have Python |
The GUI and CLI both use the `scribd_downloader` package. PDFs and `session.json` are saved in the **current working directory** (next to the `.exe` when using a built app).
---
## I — Installation
### Option 1: Pre-built Windows app (recommended for end users)
1. Build once on your PC (see [BUILD.md](BUILD.md)) or copy the `dist\Scribd PDF Downloader` folder from someone who built it.
2. Copy the **entire folder** to the target PC (do not move only the `.exe` — Chromium lives in `_internal`).
3. Run `Scribd PDF Downloader.exe`.
### Option 2: Run from source (developers)
Full steps are in [INSTALL.md](INSTALL.md). Short version:
```powershell
cd "Scribe PDF Downloader"
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
playwright install chromium
```
Then:
```powershell
.\.venv\Scripts\python.exe gui.py
# or
.\Start Scribd Downloader.bat
```
### Option 3: macOS app
Build **on a Mac** only:
```bash
./build/macos/build.sh
open "dist/Scribd PDF Downloader.app"
```
---
## D — Distribution (shipping to others)
### Windows
| Artifact | Location | Share how |
|----------|----------|-----------|
| Portable app | `dist\Scribd PDF Downloader\` | Zip the whole folder (~800 MB with Chromium) |
| Zip (optional) | `dist\Scribd-PDF-Downloader-Windows.zip` | Created by `build\windows\build.ps1` |
**Rebuild command:**
```powershell
.\build\windows\build.ps1
```
**Recipient notes:**
- No Python required.
- First run: Windows Defender / SmartScreen may warn — app is unsigned.
- Antivirus may scan `_internal` — allow if prompted.
### macOS
| Artifact | Location | Share how |
|----------|----------|-----------|
| App bundle | `dist/Scribd PDF Downloader.app` | Zip or AirDrop |
| Zip | `dist/Scribd-PDF-Downloader-macOS.zip` | From `build/macos/build.sh` |
**Recipient notes:**
- Unsigned apps: **Right-click → Open** the first time.
- Optional: `codesign --force --deep --sign - "dist/Scribd PDF Downloader.app"`
- For wide public release: Apple Developer ID + notarization.
### What is *not* in the frozen build
- Command-line `main.py` (use source + venv for CLI / `login`).
- Automatic updates — ship a new zip when you release.
---
## N — Notes (behavior & limits)
### Supported URLs
```
https://www.scribd.com/document/<id>/<title>
https://www.scribd.com/doc/<id>/<title>
https://www.scribd.com/book/<id>/<title> # needs login
```
### Documents vs ebooks
| Type | Login | Method |
|------|-------|--------|
| Document / upload | Usually no | Embed viewer → page screenshots → `img2pdf` |
| Ebook | Yes (`main.py login`) | Read viewer → print-to-PDF per page → `pypdf` merge |
### Configuration (`config.ini`)
```ini
[SETTINGS]
delay = 2.0 # seconds between page captures
scale = 2 # screenshot sharpness (1–3)
output = # optional default PDF filename
```
### Files created at runtime
| File / folder | Purpose |
|---------------|---------|
| `session.json` | Saved Scribd login (gitignored) |
| `temp_capture/` | Page images during download |
| `temp_preview/` | Preview screenshots |
| `*.pdf` | Downloaded output |
### Performance tips
- **Blurry text** → increase `scale` to `2` or `3`.
- **Missing pages** → increase `delay` to `2.5`–`3`.
- **Large docs** → use page range `-p 1-50` for a test batch first.
### Legal / ethical use
- Personal archival of content you may legally access.
- Not for bypassing paywalls or redistributing copyrighted material.
---
## A — Architecture (how it works)
```mermaid
flowchart LR
subgraph UI
GUI[gui.py]
CLI[main.py]
end
subgraph Core
URL[url.py]
PRE[preview.py]
DOC[document.py]
BOOK[book.py]
AUTH[auth.py]
end
subgraph External
PW[Playwright + Chromium]
SCR[Scribd embed / read URLs]
end
GUI --> PRE
GUI --> DOC
CLI --> DOC
CLI --> BOOK
PRE --> URL
DOC --> URL
DOC --> PW
PRE --> PW
BOOK --> AUTH
BOOK --> PW
PW --> SCR
DOC --> PDF[img2pdf → .pdf]
BOOK --> PDF2[pypdf merge → .pdf]
```
### Module roles
| Module | Role |
|--------|------|
| `url.py` | Parse Scribd URLs, build embed/read links |
| `preview.py` | Load one page screenshot for GUI preview |
| `document.py` | Capture all `.outer_page` elements, merge to PDF |
| `book.py` | Vertical reader mode, chapter-by-chapter PDF |
| `auth.py` | Login flow, `session.json`, browser context |
| `pages.py` | Parse `1-10` style page selections |
### Build pipeline (frozen app)
1. `PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium` — browsers inside the package.
2. PyInstaller reads `build/scribd_gui.spec` — bundles GUI, Playwright driver, Chromium, Tcl/Tk.
3. `build/runtime_hook.py` — sets working directory and `PLAYWRIGHT_BROWSERS_PATH=0` when frozen.
### Tech stack
- **Python 3.10+**
- **Playwright** — headless Chromium
- **Pillow** — preview images in GUI
- **img2pdf** — document PDF assembly
- **pypdf** — ebook chapter merge
- **tkinter** — desktop UI
- **PyInstaller** — Windows / macOS packages
---
## Quick reference
| Task | Command |
|------|---------|
| Open GUI (source) | `Start Scribd Downloader.bat` |
| Install deps | See [INSTALL.md](INSTALL.md) |
| Build Windows exe | `.\build\windows\build.ps1` |
| Build Mac app | `./build/macos/build.sh` |
| CLI download | `.\.venv\Scripts\python.exe main.py download "<url>"` |
| Login for books | `.\.venv\Scripts\python.exe main.py login` |
For step-by-step setup, see **[INSTALL.md](INSTALL.md)**.
For packaging details, see **[BUILD.md](BUILD.md)**.