Commit Graph

21 Commits

Author SHA1 Message Date
CaliBrain
cd16f09f2e Fix local download (#282) 2025-09-16 11:19:09 -04:00
CaliBrain
e4d3a372c8 Add retry logic for failed file copy (#261) 2025-08-29 22:32:04 -04:00
CaliBrain
c8f21b8f8d Fix progression in download (#248) 2025-08-25 23:59:05 -04:00
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
e1d94f9cb5 Update download handling and URL selection logic (#203)
Changed intermediate download file naming in backend.py to use
.crdownload extension. Refactored URL selection logic in book_manager.py
to adjust order and inclusion based on Cloudflare bypass and donator
key. Added extra Chromium arguments in cloudflare_bypasser.py to ignore
certificate and SSL errors for improved bypass reliability.
2025-07-14 16:05:09 -04:00
CaliBrain
690c2b699c Fix download for other files than epub (#174)
Fix #173
2025-05-06 08:44:43 -04:00
CaliBrain
457351fa0b Better File check (#165)
- Better file permission initialization
- Fix chown bug
2025-04-27 13:49:07 -04:00
CaliBrain
49287ac86e Revert "Better file permission initialization" (#164)
Reverts calibrain/calibre-web-automated-book-downloader#162
2025-04-27 12:43:07 -04:00
CaliBrain
4ca8298b7e Better file permission initialization (#162) 2025-04-27 01:27:48 -04:00
CaliBrain
0ba7031a83 Fix download + add test + fix book move (#140) 2025-04-16 11:18:03 -04:00
CaliBrain
e0e7470ac6 Add Backup method to move book after download (#119)
Fix #118
2025-04-04 18:10:08 -04:00
CaliBrain
93a3481750 Fix errors and improve logging (#102)
Fix #100
Fix #101
2025-03-22 17:35:12 -04:00
CaliBrain
c2e7acd473 Use a tmp name while downloading files (#99)
Should help with #98
2025-03-20 00:56:54 -04:00
CaliBrain
392a8b5262 feat: add USE_BOOK_TITLE option for customizing download filenames (#95)
Implements #94
2025-03-16 14:42:19 -04:00
CaliBrain
909f4b403c Multiple bug fixes (#93) 2025-03-16 03:33:59 -04:00
CaliBrain
d5b2e24423 feat: Add CUSTOM_SCRIPT documentation and implementation details (#90) 2025-03-16 02:40:09 -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
mik593
7f56c6b832 feat: support search filters (#55)
Still a WIP but an initial attempt of search filters. #7 

Currently supporting: 

- ISBN
- Author
- Title
- Language
- Sort
- Content


first attempt at some sort of UI for it 👇

![image](https://github.com/user-attachments/assets/7237ae96-7e97-4db0-98da-06c3171aca3b)

smaller/mobile

![image](https://github.com/user-attachments/assets/ba20de0e-deb1-4aa1-9c5f-27cf473670e6)
2025-01-22 16:51:06 -05:00
CaliBrain
b8a7247538 [FIX] Refactor code to fix typing (#23)
This also fixes some bug with the CF bypasser and the file checker
2024-12-22 22:11:35 -05:00
CaliBrain
7597054649 Fix #20 : Network error when using alternative download streams (#22) 2024-12-22 19:25:03 -05:00
CaliBrain
18b146af64 Innitial Release 2024-12-16 22:48:26 +00:00