Adds MP3 Chapter Renaming and Refactors Core Architecture #46

Merged
AlexKucera merged 17 commits from feature/rename-mp3 into develop 2026-06-06 09:52:08 +02:00
4 changed files with 21 additions and 5 deletions
Showing only changes of commit 8acea390e6 - Show all commits

No files matched your search

+7
View File
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Fixed
- **downloader:** Fix progress bar exceeding 100% on resumed downloads.
`Content-Length` from a Range response covers only remaining bytes;
now adds `resume_from` for the true total.
- **session:** Stop reaching into `httpx.Client._transport` (private API).
Transport reference is now stored at construction time.
### Added ### Added
+4 -1
View File
@@ -109,7 +109,10 @@ def _stream_to_file(
if content_length is None: if content_length is None:
cl_header = resp.headers.get("content-length") cl_header = resp.headers.get("content-length")
if cl_header: if cl_header:
content_length = int(cl_header) # Content-Length from a Range response
# covers only remaining bytes; add
# resume_from for true total.
content_length = int(cl_header) + resume_from
progress(downloaded, total=content_length) progress(downloaded, total=content_length)
else: else:
progress(downloaded) progress(downloaded)
1
+8 -3
View File
@@ -47,6 +47,7 @@ class LibroFmSession:
self._timeout = timeout self._timeout = timeout
self._access_token: str | None = None self._access_token: str | None = None
self._api_semaphore = threading.Semaphore(API_SEMAPHORE_CAPACITY) self._api_semaphore = threading.Semaphore(API_SEMAPHORE_CAPACITY)
self._transport = transport
self._client = httpx.Client( self._client = httpx.Client(
base_url=self._base_url, base_url=self._base_url,
1
@@ -56,9 +57,13 @@ class LibroFmSession:
) )
@property @property
def transport(self) -> httpx.BaseTransport: def transport(self) -> httpx.BaseTransport | None:
"""Return the underlying httpx transport for streaming downloads.""" """Return the httpx transport for streaming downloads.
return self._client._transport
Stored at construction time to avoid reaching into
``httpx.Client._transport``, which is private API.
"""
return self._transport
def authenticate(self) -> str: def authenticate(self) -> str:
"""OAuth2 password grant → returns access_token. """OAuth2 password grant → returns access_token.
+2 -1
View File
@@ -712,7 +712,8 @@ class TestTransportProperty:
password="p", password="p",
) )
assert session.transport is session._client._transport # Default transport is None when not injected
assert session.transport is None
def test_returns_injected_mock_transport(self): def test_returns_injected_mock_transport(self):
"""When a MockTransport is injected, session.transport returns it.""" """When a MockTransport is injected, session.transport returns it."""