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>
This commit is contained in:
CaliBrain
2025-03-16 02:25:15 -04:00
committed by GitHub
co-authored by mik593
parent 17fdb87749
commit 3a92c5de78
19 changed files with 688 additions and 264 deletions
+8 -7
View File
@@ -3,8 +3,10 @@
from dataclasses import dataclass, field
from typing import Dict, List, Optional
from enum import Enum
from config import INGEST_DIR, STATUS_TIMEOUT
from datetime import datetime, timedelta
from threading import Lock
from config import INGEST_DIR, STATUS_TIMEOUT
class QueueStatus(str, Enum):
"""Enum for possible book queue statuses."""
@@ -31,13 +33,12 @@ class BookInfo:
class BookQueue:
"""Thread-safe book queue manager."""
def __init__(self):
from threading import Lock
self._queue = set()
def __init__(self) -> None:
self._queue: set[str] = set()
self._lock = Lock()
self._status = {}
self._book_data = {}
self._status_timestamps = {} # Track when each status was last updated
self._status: dict[str, QueueStatus] = {}
self._book_data: dict[str, BookInfo]= {}
self._status_timestamps: dict[str, datetime] = {} # Track when each status was last updated
self._status_timeout = timedelta(seconds=STATUS_TIMEOUT) # 1 hour timeout
def add(self, book_id: str, book_data: BookInfo) -> None: