Compare commits

..

3 Commits

Author SHA1 Message Date
f2c9d683b6 chore: update lock 2026-02-12 19:19:54 +01:00
b530238494 feat: now display download status in MB 2026-02-12 19:19:48 +01:00
89073aaf95 fix: progress bar centered 2026-02-12 19:19:36 +01:00
3 changed files with 25 additions and 12 deletions

View File

@@ -122,9 +122,11 @@ ProgressBar#progress_bar {
border: none; border: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
width: auto; width: 50%;
min-width: 40; }
max-width: 80;
ProgressBar#progress_bar Bar {
width: 100%;
} }
ProgressBar#progress_bar > .progress-bar--track { ProgressBar#progress_bar > .progress-bar--track {

View File

@@ -9,7 +9,13 @@ import audible
import httpx import httpx
from audible.activation_bytes import get_activation_bytes from audible.activation_bytes import get_activation_bytes
from .constants import CACHE_DIR, DEFAULT_CHUNK_SIZE, DEFAULT_CODEC, DOWNLOAD_URL, MIN_FILE_SIZE from .constants import (
CACHE_DIR,
DEFAULT_CHUNK_SIZE,
DEFAULT_CODEC,
DOWNLOAD_URL,
MIN_FILE_SIZE,
)
StatusCallback = Callable[[str], None] StatusCallback = Callable[[str], None]
@@ -29,15 +35,15 @@ class DownloadManager:
self.cache_dir = cache_dir self.cache_dir = cache_dir
self.cache_dir.mkdir(parents=True, exist_ok=True) self.cache_dir.mkdir(parents=True, exist_ok=True)
self.chunk_size = chunk_size self.chunk_size = chunk_size
self._http_client = httpx.Client( self._http_client = httpx.Client(auth=auth, timeout=30.0, follow_redirects=True)
auth=auth, timeout=30.0, follow_redirects=True)
self._download_client = httpx.Client( self._download_client = httpx.Client(
timeout=httpx.Timeout(connect=30.0, read=None, timeout=httpx.Timeout(connect=30.0, read=None, write=30.0, pool=30.0),
write=30.0, pool=30.0),
follow_redirects=True, follow_redirects=True,
) )
def get_or_download(self, asin: str, notify: StatusCallback | None = None) -> Path | None: def get_or_download(
self, asin: str, notify: StatusCallback | None = None
) -> Path | None:
"""Get local path of AAX file, downloading if missing.""" """Get local path of AAX file, downloading if missing."""
title = self._get_name_from_asin(asin) or asin title = self._get_name_from_asin(asin) or asin
safe_title = self._sanitize_filename(title) safe_title = self._sanitize_filename(title)
@@ -140,7 +146,10 @@ class DownloadManager:
return None return None
def _get_download_link( def _get_download_link(
self, asin: str, codec: str = DEFAULT_CODEC, notify: StatusCallback | None = None self,
asin: str,
codec: str = DEFAULT_CODEC,
notify: StatusCallback | None = None,
) -> str | None: ) -> str | None:
"""Get download link for book.""" """Get download link for book."""
if self.auth.adp_token is None: if self.auth.adp_token is None:
@@ -193,8 +202,10 @@ class DownloadManager:
downloaded += len(chunk) downloaded += len(chunk)
if total_size > 0 and notify: if total_size > 0 and notify:
percent = (downloaded / total_size) * 100 percent = (downloaded / total_size) * 100
downloaded_mb = downloaded / (1024 * 1024)
total_mb = total_size / (1024 * 1024)
notify( notify(
f"Downloading: {percent:.1f}% ({downloaded}/{total_size} bytes)" f"Downloading: {percent:.1f}% ({downloaded_mb:.1f}/{total_mb:.1f} MB)"
) )
return dest_path return dest_path

2
uv.lock generated
View File

@@ -35,7 +35,7 @@ wheels = [
[[package]] [[package]]
name = "auditui" name = "auditui"
version = "0.1.4" version = "0.1.5"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "audible" }, { name = "audible" },