Add Scribd PDF Downloader under Scribd/
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
5d2933ea95
28 files changed
+2159
No files matched your search
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build macOS .app bundle — run ON A MAC from project root:
|
||||
# chmod +x build/macos/build.sh
|
||||
# ./build/macos/build.sh
|
||||
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
echo "=== Scribd PDF Downloader — macOS build ==="
|
||||
|
||||
if [[ "$(uname)" != "Darwin" ]]; then
|
||||
echo "Error: macOS builds must run on a Mac (MacBook Pro, etc.)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d .venv ]]; then
|
||||
echo "Creating virtual environment..."
|
||||
python3 -m venv .venv
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source .venv/bin/activate
|
||||
|
||||
pip install -r requirements-build.txt -q
|
||||
|
||||
echo "Installing Chromium into package (for bundling)..."
|
||||
export PLAYWRIGHT_BROWSERS_PATH=0
|
||||
playwright install chromium
|
||||
|
||||
echo "Running PyInstaller..."
|
||||
pyinstaller --noconfirm --clean build/scribd_gui.spec
|
||||
|
||||
APP="dist/Scribd PDF Downloader.app"
|
||||
if [[ ! -d "$APP" ]]; then
|
||||
echo "Error: $APP not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp -f config.ini "$APP/Contents/MacOS/" 2>/dev/null || cp -f config.ini "$APP/Contents/Resources/" 2>/dev/null || true
|
||||
|
||||
ZIP="dist/Scribd-PDF-Downloader-macOS.zip"
|
||||
rm -f "$ZIP"
|
||||
ditto -c -k --sequesterRsrc --keepParent "$APP" "$ZIP"
|
||||
|
||||
echo ""
|
||||
echo "Build complete!"
|
||||
echo " App: $APP"
|
||||
echo " Zip: $ZIP"
|
||||
echo ""
|
||||
echo "First launch: right-click → Open (Gatekeeper) if macOS blocks the app."
|
||||
echo "Optional signing: codesign --force --deep --sign - \"$APP\""
|
||||
@@ -0,0 +1,17 @@
|
||||
"""PyInstaller runtime hook — configure paths when running as a frozen app."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def _app_dir() -> str:
|
||||
if getattr(sys, "frozen", False):
|
||||
return os.path.dirname(sys.executable)
|
||||
return os.getcwd()
|
||||
|
||||
|
||||
if getattr(sys, "frozen", False):
|
||||
os.chdir(_app_dir())
|
||||
os.environ.setdefault("PLAYWRIGHT_BROWSERS_PATH", "0")
|
||||
@@ -0,0 +1,98 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
# PyInstaller spec for Scribd PDF Downloader (GUI).
|
||||
# Build from project root:
|
||||
# .\build\windows\build.ps1
|
||||
# ./build/macos/build.sh
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import playwright
|
||||
|
||||
block_cipher = None
|
||||
# SPECPATH is the directory containing this spec file (build/)
|
||||
ROOT = Path(SPECPATH).parent
|
||||
HOOKS = Path(playwright.__file__).parent / "_impl" / "__pyinstaller"
|
||||
|
||||
datas = [(str(ROOT / "config.ini"), ".")]
|
||||
|
||||
hiddenimports = [
|
||||
"scribd_downloader",
|
||||
"scribd_downloader.auth",
|
||||
"scribd_downloader.book",
|
||||
"scribd_downloader.document",
|
||||
"scribd_downloader.pages",
|
||||
"scribd_downloader.preview",
|
||||
"scribd_downloader.url",
|
||||
"playwright",
|
||||
"playwright.sync_api",
|
||||
"playwright.sync_api._generated",
|
||||
"greenlet",
|
||||
"img2pdf",
|
||||
"pikepdf",
|
||||
"PIL",
|
||||
"PIL.Image",
|
||||
"PIL.ImageTk",
|
||||
]
|
||||
|
||||
a = Analysis(
|
||||
[str(ROOT / "gui.py")],
|
||||
pathex=[str(ROOT)],
|
||||
binaries=[],
|
||||
datas=datas,
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[str(HOOKS)],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[str(ROOT / "build" / "runtime_hook.py")],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name="Scribd PDF Downloader",
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=False,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=False,
|
||||
upx_exclude=[],
|
||||
name="Scribd PDF Downloader",
|
||||
)
|
||||
|
||||
# macOS .app bundle (only used when building on Darwin)
|
||||
if sys.platform == "darwin":
|
||||
app = BUNDLE(
|
||||
coll,
|
||||
name="Scribd PDF Downloader.app",
|
||||
icon=None,
|
||||
bundle_identifier="com.scribd.pdfdownloader",
|
||||
info_plist={
|
||||
"CFBundleName": "Scribd PDF Downloader",
|
||||
"CFBundleDisplayName": "Scribd PDF Downloader",
|
||||
"CFBundleVersion": "1.0.0",
|
||||
"CFBundleShortVersionString": "1.0.0",
|
||||
"NSHighResolutionCapable": True,
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,46 @@
|
||||
# Build Windows portable app (folder with Scribd PDF Downloader.exe)
|
||||
# Run from project root: .\build\windows\build.ps1
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = Resolve-Path (Join-Path $PSScriptRoot "..\..")
|
||||
Set-Location $Root
|
||||
|
||||
Write-Host "=== Scribd PDF Downloader - Windows build ===" -ForegroundColor Cyan
|
||||
|
||||
if (-not (Test-Path ".venv\Scripts\python.exe")) {
|
||||
Write-Host "Creating virtual environment..."
|
||||
python -m venv .venv
|
||||
}
|
||||
|
||||
Write-Host "Installing dependencies..."
|
||||
& .venv\Scripts\pip install -r requirements-build.txt -q
|
||||
|
||||
Write-Host "Installing Chromium into package (for bundling)..."
|
||||
$env:PLAYWRIGHT_BROWSERS_PATH = "0"
|
||||
& .venv\Scripts\playwright install chromium
|
||||
|
||||
Write-Host "Running PyInstaller..."
|
||||
& .venv\Scripts\pyinstaller --noconfirm --clean "build\scribd_gui.spec"
|
||||
|
||||
$Dist = Join-Path $Root "dist\Scribd PDF Downloader"
|
||||
if (-not (Test-Path $Dist)) {
|
||||
throw "Build failed: dist folder not found."
|
||||
}
|
||||
|
||||
Copy-Item "config.ini" $Dist -Force -ErrorAction SilentlyContinue
|
||||
|
||||
$Zip = Join-Path $Root "dist\Scribd-PDF-Downloader-Windows.zip"
|
||||
if (Test-Path $Zip) { Remove-Item $Zip -Force }
|
||||
Start-Sleep -Seconds 2
|
||||
try {
|
||||
Compress-Archive -Path $Dist -DestinationPath $Zip -Force
|
||||
} catch {
|
||||
Write-Host "Zip skipped (copy the dist folder instead): $_" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Build complete!" -ForegroundColor Green
|
||||
Write-Host " App folder: $Dist"
|
||||
Write-Host " Zip archive: $Zip"
|
||||
Write-Host ""
|
||||
Write-Host ('Run: "' + (Join-Path $Dist 'Scribd PDF Downloader.exe') + '"')
|
||||
Reference in new issue
Block a user