Commit Graph

12 Commits

Author SHA1 Message Date
Stephon Parker
5e04b6bfb8 Add Download Queue Management & Concurrent Downloads (#231)
## Summary

This PR completely overhauls the download system to support concurrent
downloads, cancellation, and advanced queue
management. No more waiting for stuck downloads to block the entire
queue!

  ## New Features

  ###  **Concurrent Downloads**
  - **3 simultaneous downloads** by default (configurable)
- ThreadPoolExecutor-based architecture replaces single-threaded
bottleneck
  - Downloads no longer block each other

  ###  **Download Cancellation**
  - **Cancel button** for active/queued downloads
  - Clean cancellation with partial file cleanup
  - Thread-safe cancellation flags

  ### **Queue Priority & Reordering**
  - **Priority-based queue** (lower number = higher priority)
  - **Editable priority inputs** in UI for queued items
  - **Bulk reordering** API support

  ## UI Enhancements

- **Enhanced status table** with Priority, Progress, and Actions columns
  - **Progress bars** for active downloads
  - **Cancel buttons** for downloads
- **Queue management controls**: Refresh, Clear Completed, Active
Counter
  - **Real-time updates** every 60 seconds

## Implementation

  ### New Architecture
  - `queue.PriorityQueue` replaces simple `set()` for proper ordering
  - `concurrent.futures.ThreadPoolExecutor` handles worker threads
  - `threading.Event` flags enable clean cancellation
  - Thread-safe operations with proper locking

  ### New API Endpoints
  DELETE /api/download/{id}/cancel     # Cancel downloads
PUT /api/queue/{id}/priority # Set priorityPOST /api/queue/reorder #
Bulk reorder
  GET /api/downloads/active          # Active tracking
  DELETE /api/queue/clear            # Clear completed

  ### New Environment Variables
  ```bash
  MAX_CONCURRENT_DOWNLOADS=3          # Worker thread count
  DOWNLOAD_PROGRESS_UPDATE_INTERVAL=5  # Progress frequency
  ```

### Fully backward compatible - existing functionality unchanged

### Fixes

  - Resolves: Downloads blocking when one gets stuck
  - Resolves: No way to cancel problematic downloads
  - Resolves: No queue management or prioritization
  
  #183

---------

Co-authored-by: CaliBrain <calibrain@l4n.xyz>
2025-08-25 13:28:35 -04:00
CaliBrain
3ae129119d Fix Seleniumbase (#229) 2025-08-19 12:41:27 -04:00
Borderpatrol1987
8a13a503b2 Update docker-compose.yml (#228)
Added container name to compose.yml
2025-08-19 12:15:32 -04:00
Timothy Allen
086401083e Add simple authentication (#181)
This commit adds user authentication, using Calibre-Web's app.db as its
authentication source, as requested in #56. It uses @prinzpi's
[comment](https://github.com/calibrain/calibre-web-automated-book-downloader/issues/56#issuecomment-2919335169)
as a starting point, but integrates the logic directly into the app.

This requires the user to specify the environment variable CONFIG_ROOT,
set to Calibre-Web's config directory (the directory that contains the
app.db database that holds the user's authentication information).

If the user does not wish to add authentication, they can simply leave
CONFIG_ROOT unset, or not pointing at Calibre-Web's app.db directory.
2025-06-15 00:55:25 -04:00
CaliBrain
712f71a466 Add DEBUG button (#147) 2025-04-20 05:32:11 -04:00
CaliBrain
666d7ba849 Refactor Cloudflare Bypass & Fix Bugs (#126) 2025-04-13 13:01:15 -04:00
CaliBrain
57f15b4d95 Tor support, use SeleniumBase instead of DrissionPage (#123)
Refactor: Improve Docker build, add Tor support, use SeleniumBase

- Overhauled Dockerfile:
    - Switched to python:3.10-slim base.
    - Implemented multi-stage builds (base, standard, tor).
    - Consolidated RUN layers for efficiency.
    - Added locale/timezone setup.
- Added Tor setup and iptables configuration in dedicated stage/script.
- Replaced DrissionPage with SeleniumBase for Cloudflare bypassing.
- Added Tor support via `docker-compose.tor.yml` and `tor.sh` script.
- Updated `docker-compose.yml` to build locally and changed default port
to 8083.
- Added `docker-compose.dev.yml` and `docker-compose.tor.dev.yml`.
- Updated `entrypoint.sh` for timezone and sudo usage.
- Added/Updated environment variables (`TZ`, `USING_TOR`, etc.).
- Improved `.dockerignore`.
- Updated `readme.md` to reflect port changes, build process, document
`TZ`, and add details about the new Tor variant.
2025-04-13 02:34:39 -04:00
CaliBrain
3a92c5de78 CF BYPASS (#24)
The Calibre dependency was due to the script testing for validity of the
downloaded file, as often they would be corrupted from aa. But CWA is
already doing that, so we are just having redundant code here.

For the cloudflarebypasser, I basically run my own version now, instead
of depending on an external library, this way we have better control for
debugging and on the docker image.

Fixes #18, #33, #27, #48, #65, #78, #86, #88, #89

---------

Co-authored-by: mik593 <91991279+mik593@users.noreply.github.com>
2025-03-16 02:25:15 -04:00
CaliBrain
7597054649 Fix #20 : Network error when using alternative download streams (#22) 2024-12-22 19:25:03 -05:00
CaliBrain
c9b64b2337 Fix compose port (#13) 2024-12-19 16:57:56 -05:00
BastianLo
d9a6d599e6 make book language configurable (#1) 2024-12-18 08:39:03 -05:00
CaliBrain
18b146af64 Innitial Release 2024-12-16 22:48:26 +00:00