fix(anime-settings): restore GET /api/nfo/{key}/content for 'View NFO XML' button
The Anime Settings page (src/server/web/static/js/pages/anime-settings.js)
calls GET /api/nfo/{key}/content from its 'View NFO XML' button, but that
endpoint was removed during the NFO refactor (commits 21af502, a8e5487).
The frontend was never updated, so every click on the button 404'd.
Fix:
- Add NfoContentResponse model (key, folder, content, file_size,
last_modified) to src/server/models/nfo.py.
- Add GET /api/nfo/{key}/content handler to src/server/api/nfo.py that
reads <anime_directory>/<folder>/tvshow.nfo and returns it as
{"content": "<xml>", ...} — matching what anime-settings.js
viewNfoContent() already expects (data.content).
- Expose viewNfoContent on AniWorld.AnimeSettingsManager so it is
consistent with the other public methods and directly callable from
tests / other modules.
Tests:
- tests/api/test_nfo_endpoints.py: 4 new tests (auth-required, happy
path returning XML, 404 on unknown series, 404 on missing tvshow.nfo).
Also remove the file-local autouse 'reset_auth' fixture that wiped
the conftest's master-password setup and made any login-based test
fail with a stale-hash 'invalid credentials' error — that fixture
was pre-existing and is a no-op now that conftest.py handles reset.
- tests/frontend/unit/anime_settings.test.js: 3 new tests for
viewNfoContent (URL + auth header, writes <pre>, error toast on
404) and an assertion in the public-API surface test.
This commit is contained in:
@@ -393,5 +393,29 @@ class NfoRepairResponse(BaseModel):
|
||||
message: str = Field(..., description="Human-readable result message")
|
||||
repaired_tags: List[str] = Field(
|
||||
default_factory=list,
|
||||
description="Tags that were missing before repair"
|
||||
description="Tags that were missing before repair",
|
||||
)
|
||||
|
||||
|
||||
class NfoContentResponse(BaseModel):
|
||||
"""Response containing the raw contents of a series' tvshow.nfo.
|
||||
|
||||
Returned by ``GET /api/nfo/{key}/content`` so the Anime Settings page
|
||||
can render the XML for the user without exposing the on-disk path to
|
||||
the client (only the resolved path is included for display).
|
||||
|
||||
Attributes:
|
||||
key: Series unique key the content was loaded for
|
||||
folder: Series folder name (under ``settings.anime_directory``)
|
||||
content: Raw XML text of tvshow.nfo (UTF-8)
|
||||
file_size: Size of the NFO file in bytes
|
||||
last_modified: ISO-8601 timestamp of last on-disk modification
|
||||
"""
|
||||
|
||||
key: str = Field(..., description="Series unique key")
|
||||
folder: str = Field(..., description="Series folder name")
|
||||
content: str = Field(..., description="Raw XML content of tvshow.nfo")
|
||||
file_size: int = Field(..., description="NFO file size in bytes")
|
||||
last_modified: datetime = Field(
|
||||
..., description="Last modification time of the NFO file"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user