mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-10-05 22:05:50 +01:00
Base url additions and bug fixes (#519)
- Base URL option in settings for reverse proxy setups - Fix NZB downloads not deleting on completion - Fix handling for audiobook files over 100+ parts - Fix prowlarr search timeout - Fix prowlarr categorisation for expanded searches
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
from shelfmark.metadata_providers import BookMetadata
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
|
||||
class TestReleaseSearchPlanManualQuery:
|
||||
def test_manual_query_overrides_plan(self, monkeypatch):
|
||||
import shelfmark.release_sources.search_plan as sp
|
||||
import shelfmark.core.search_plan as sp
|
||||
|
||||
monkeypatch.setattr(sp.config, "BOOK_LANGUAGE", ["en", "hu"], raising=False)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from shelfmark.metadata_providers import BookMetadata
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
|
||||
class TestReleaseSearchPlan:
|
||||
def test_uses_default_languages_when_none(self, monkeypatch):
|
||||
# config.BOOK_LANGUAGE is a Config attribute; patch the instance.
|
||||
import shelfmark.release_sources.search_plan as sp
|
||||
import shelfmark.core.search_plan as sp
|
||||
|
||||
monkeypatch.setattr(sp.config, "BOOK_LANGUAGE", ["en", "hu"], raising=False)
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestReleaseSearchPlan:
|
||||
]
|
||||
|
||||
def test_all_language_disables_grouping(self, monkeypatch):
|
||||
import shelfmark.release_sources.search_plan as sp
|
||||
import shelfmark.core.search_plan as sp
|
||||
|
||||
monkeypatch.setattr(sp.config, "BOOK_LANGUAGE", ["en"], raising=False)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from shelfmark.metadata_providers import BookMetadata
|
||||
from shelfmark.release_sources.direct_download import DirectDownloadSource
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
|
||||
class TestDirectDownloadSearchQueries:
|
||||
|
||||
@@ -12,6 +12,7 @@ from shelfmark.release_sources.prowlarr.source import (
|
||||
_parse_size,
|
||||
_extract_format,
|
||||
_extract_language,
|
||||
_detect_content_type_from_categories,
|
||||
)
|
||||
from shelfmark.release_sources.prowlarr.utils import get_protocol_display, sanitize_download_url
|
||||
from shelfmark.metadata_providers import BookMetadata
|
||||
@@ -247,6 +248,26 @@ class TestExtractLanguage:
|
||||
assert _extract_language("Book [German]") == "de"
|
||||
|
||||
|
||||
class TestDetectContentType:
|
||||
"""Tests for the _detect_content_type_from_categories function."""
|
||||
|
||||
def test_fallback_without_categories(self):
|
||||
assert _detect_content_type_from_categories([], "ebook") == "book"
|
||||
assert _detect_content_type_from_categories([], "audiobook") == "audiobook"
|
||||
|
||||
def test_audiobook_categories(self):
|
||||
assert _detect_content_type_from_categories([{"id": 3030}], "ebook") == "audiobook"
|
||||
assert _detect_content_type_from_categories([3000], "ebook") == "audiobook"
|
||||
|
||||
def test_book_category_range(self):
|
||||
assert _detect_content_type_from_categories([{"id": 7000}], "ebook") == "book"
|
||||
assert _detect_content_type_from_categories([7020], "audiobook") == "book"
|
||||
assert _detect_content_type_from_categories([7030], "ebook") == "book"
|
||||
|
||||
def test_non_book_categories_return_other(self):
|
||||
assert _detect_content_type_from_categories([{"id": 2000}], "ebook") == "other"
|
||||
|
||||
|
||||
class TestProwlarrLocalizedQueries:
|
||||
def test_manual_query_still_applies_content_type_categories(self, monkeypatch):
|
||||
class FakeClient:
|
||||
@@ -279,7 +300,7 @@ class TestProwlarrLocalizedQueries:
|
||||
authors=["Someone"],
|
||||
)
|
||||
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
plan = build_release_search_plan(book, languages=["en"], manual_query="my custom")
|
||||
source.search(book, plan, content_type="audiobook")
|
||||
@@ -317,7 +338,7 @@ class TestProwlarrLocalizedQueries:
|
||||
authors=["Someone"],
|
||||
)
|
||||
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
plan = build_release_search_plan(book, languages=["en"], manual_query="my custom")
|
||||
source.search(book, plan, expand_search=True, content_type="audiobook")
|
||||
@@ -356,7 +377,7 @@ class TestProwlarrLocalizedQueries:
|
||||
titles_by_language={"hu": "A villámtolvaj"},
|
||||
)
|
||||
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
plan = build_release_search_plan(book, languages=["en", "hu"])
|
||||
source.search(book, plan, content_type="ebook")
|
||||
@@ -402,7 +423,7 @@ class TestProwlarrLocalizedQueries:
|
||||
},
|
||||
)
|
||||
|
||||
from shelfmark.release_sources.search_plan import build_release_search_plan
|
||||
from shelfmark.core.search_plan import build_release_search_plan
|
||||
|
||||
plan = build_release_search_plan(book, languages=["en", "hu"])
|
||||
source.search(book, plan, content_type="ebook")
|
||||
|
||||
Reference in New Issue
Block a user