Unify movies and series list, add TMDb-sourced tags and detail panel

This commit is contained in:
2026-09-09 07:13:36 +02:00
parent 79c9e34a5d
commit c0ad1c1553
5 changed files with 376 additions and 108 deletions
+40
View File
@@ -67,6 +67,46 @@ def test_search_movie_empty_query_skips_network(monkeypatch):
assert tmdb.search_movie(" ") == []
def test_movie_details_maps_fields(monkeypatch):
payload = {
"id": 603, "title": "Matrix", "release_date": "1999-03-31",
"vote_average": 8.3,
"genres": [{"id": 28, "name": "Akční"}, {"id": 878, "name": "Vědeckofantastický"}],
"production_countries": [{"iso_3166_1": "US", "name": "United States of America"}],
}
monkeypatch.setattr(tmdb.requests, "get", lambda *a, **k: _resp(200, payload))
d = tmdb.movie_details(603)
assert d.genres == ["Akční", "Vědeckofantastický"]
assert d.countries == ["United States of America"]
assert d.rating == 83 and d.year == "1999"
assert d.field_values("genres") == ["Akční", "Vědeckofantastický"]
assert d.field_values("rating") == ["83"]
def test_refresh_tags_from_tmdb(tmp_path, monkeypatch):
monkeypatch.setattr("src.core.config.GLOBAL_CONFIG_FILE", tmp_path / ".gtag")
from src.core.tag_manager import TagManager
from src.core.file_manager import FileManager
from src.core.tmdb import TmdbDetails
fm = FileManager(TagManager())
fm.set_pool_dir(tmp_path / "pool")
(tmp_path / "a.mkv").write_bytes(b"x")
(tmp_path / "b.mkv").write_bytes(b"y")
matched = fm.import_movie(tmp_path / "a.mkv", "Matrix", year=1999, tmdb_id=603)
fm.import_movie(tmp_path / "b.mkv", "Bez ID", year=2000) # no tmdbid
import src.core.tmdb as tmdb_mod
monkeypatch.setattr(tmdb_mod, "movie_details", lambda i: TmdbDetails(
int(i), "Matrix", "1999", ["Akční", "Sci-Fi"], ["USA"], 83))
result = fm.refresh_tags_from_tmdb()
assert result == {"ok": True, "updated": 1, "without_id": 1, "errors": []}
paths = {t.full_path for t in matched.tags}
assert {"Žánr/Akční", "Žánr/Sci-Fi", "Rok/1999", "Země původu/USA"} <= paths
assert matched.meta == {"year": "1999", "rating": 83}
def test_missing_key_raises(monkeypatch):
monkeypatch.delenv("TMDB_API_KEY", raising=False)
with pytest.raises(TmdbError):