Commit Graph

21 Commits

Author SHA1 Message Date
EstrellaXD
3f4f3a141c feat(database): add title alias system for mid-season naming changes
When subtitle groups change their naming convention mid-season (e.g.,
"LoliHouse" → "LoliHouse&动漫国"), AutoBangumi was creating duplicate
entries. This adds a title alias system that:

- Detects semantic duplicates (same official_title, dpi, subtitle,
  source, and similar group name)
- Merges them as aliases instead of creating new entries
- Updates match_torrent() and match_list() to check aliases
- Adds title_aliases field to Bangumi model (JSON list)
- Includes migration v8 for the new column
- Adds 10 new tests for the feature
- Fixes cache invalidation bug in disable_rule()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:44:44 +01:00
EstrellaXD
3c71cf813f fix(offset): only suggest episode_offset for virtual seasons
- Change episode_offset type from int to int | None
- Only set episode_offset when virtual season split is detected
- For simple season mismatches (e.g., RSS S2 → TMDB S1), episode_offset is now None
- Improve reason messages to clarify when episode offset is/isn't needed
- Update database migration version to 7 and add migration check

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:51:55 +01:00
EstrellaXD
01a1a79a33 feat(offset): add suggested offset values to review panel
When offset scanner detects a mismatch, it now stores:
- suggested_season_offset: recommended season offset value
- suggested_episode_offset: recommended episode offset value

These values are returned in the API response for bangumi that need review,
allowing the frontend to display them to help users configure the correct offset.

Database migration v7 adds the new columns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:45:40 +01:00
Estrella Pan
34332d27af fix(renamer): resolve multiple rows error for multi-subscription seasons
When multiple bangumi subscriptions share the same save_path (e.g., split-cour
anime with S01E1-12 and S01E13-24), the renamer's match_by_save_path() query
returned multiple rows causing "Multiple rows were found" errors.

Changes:
- Add qb_hash field to Torrent model for direct hash-to-bangumi linking
- Add database migration v6 for qb_hash column with index
- Add tags parameter to add_torrents() in all downloader clients
- Tag new torrents with ab:{bangumi_id} for offset lookup during rename
- Implement multi-tier lookup in renamer: qb_hash -> tags -> torrent_name -> save_path
- Fix auth tests by mocking DEV_AUTH_BYPASS for proper 401 testing

The renamer now reliably finds the correct bangumi and its offsets even when
multiple subscriptions download to the same directory.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-01-26 08:20:02 +01:00
Estrella Pan
66c7127f21 feat(offset): add automatic season/episode offset detection
- Add offset detector to identify season mismatches between RSS and TMDB
- Only suggest season_offset (user sets episode_offset manually)
- Add background scanner for existing bangumi rules
- Add detect-offset and dismiss-review API endpoints
- Add warning banner in edit dialog with auto-detect button
- Add iOS-style notification badge for needs_review items
- Yellow badge with "!" for warnings, purple badge for multi-rule count
- Combined badge shows "! | 2" when both conditions apply
- Yellow glow animation on cards needing review
- Highlight warning items in rule selection popup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 21:03:18 +01:00
Estrella Pan
d2bf733a3e feat(database): auto-fill NULL values with model defaults during migration
When migrating from older versions, new columns may have NULL values.
This adds a generic mechanism that scans all table models and fills
NULL values based on field defaults defined in SQLModel, improving
data consistency for upgraded databases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:13:17 +01:00
Estrella Pan
55b15ea8fe feat: add bangumi archive and episode offset features (#958)
* feat: add bangumi archive and episode offset features

Archive Feature:
- Add archived field to Bangumi model with database migration (v4)
- Add archive/unarchive API endpoints (PATCH /bangumi/archive/{id})
- Add auto-archive for ended series via TMDB metadata refresh
- Add collapsible archived section in UI with visual styling
- Add archive/unarchive button in edit rule popup

Episode Offset Feature:
- Extract series_status and season_episode_counts from TMDB API
- Add suggest-offset API endpoint with auto-detection logic
- Apply offset in renamer gen_path() for episode numbering
- Add offset field with "Auto Detect" button in rule editor
- Look up offset from database when renaming files

The offset auto-detection calculates the sum of episodes from all
previous seasons (e.g., if S01 has 13 episodes, S02E18 → S02E05
with offset=-13).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add changelog for bangumi archive and episode offset features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:13:49 +01:00
Estrella Pan
ce5b23ea03 fix(db): resolve DetachedInstanceError and missing passkey table (#956)
- Fix DetachedInstanceError in bangumi cache by expunging objects from
  session before caching, preventing lazy loading errors when cached
  objects are accessed from different request contexts

- Add database migration v3 to create passkey table for WebAuthn support,
  fixing "no such table: passkey" error for users upgrading from older
  versions

Closes #956

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-01-25 07:52:00 +01:00
Estrella Pan
c5f4919e15 feat(rss): add connection status tracking and display
Track RSS feed reachability during refresh cycles. Each feed now stores
connection_status (healthy/error), last_checked_at, and last_error.
The RSS management page shows a green "Connected" tag for healthy feeds
and a red "Error" tag with tooltip for failed feeds.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 21:45:04 +01:00
Estrella Pan
dcc60ce9a5 fix(db,downloader): fix server error on upgrade from 3.1.x to 3.2.x (#956)
- Fix 'dict' object has no attribute 'files' in renamer by using dict
  access for qBittorrent API responses and fetching file lists via
  separate torrents/files endpoint
- Replace version-file-based migration with schema_version table to
  reliably track and apply database migrations on every startup
- Add air_weekday column migration as versioned migration entry
- Add torrents_files method to QbDownloader and Aria2Downloader

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-01-24 18:26:57 +01:00
EstrellaXD
2a757e8f2c feat: add calendar view with Bangumi.tv schedule integration
Add weekly broadcast schedule page showing subscribed anime grouped by
day-of-week. Backend fetches air_weekday from Bangumi.tv calendar API
and matches titles. Frontend displays responsive grid (desktop) and
vertical list (mobile). Edit popup moved to parent layout to fix
KeepAlive conflicts, and restyled with purple theme.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 17:51:19 +01:00
EstrellaXD
cd233881bd fix(backend): restore sync Database interface, isolate async for passkey
The previous refactoring broke backward compatibility by converting
Database from Session-extending sync class to a standalone async class.
This broke RSSEngine, startup code, and auth flows.

- Restore Database(Session) with sync interface for legacy code
- Restore UserDatabase to sync methods
- Restore security/api.py and auth.py to sync calls
- Passkey API now uses async_session_factory directly
- PasskeyAuthStrategy uses async sessions independently
- Remove unused db_session from engine.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:59:26 +01:00
EstrellaXD
027222a24d fix: resolve WebAuthn passkey compatibility with py_webauthn 2.7.0
- Fix aaguid type (str not bytes) in registration verification
- Fix missing credential_backup_eligible field (use credential_device_type)
- Remove invalid credential_id param from verify_authentication_response
- Fix origin detection to use browser Origin header for WebAuthn verification
- Add async database engine support (aiosqlite) for passkey operations
- Convert UserDatabase to async-compatible with sync/async session detection
- Update Database class to support both sync and async context managers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:07:18 +01:00
EstrellaXD
d2cfd9b150 feat: add WebAuthn passkey authentication support
- Add passkey login as alternative authentication method
- Support multiple passkeys per user with custom names
- Backend: WebAuthn service, auth strategy pattern, API endpoints
- Frontend: passkey management UI in settings, login option
- Fix: convert downloader check from sync requests to async httpx
  to prevent blocking the event loop when downloader unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 14:57:00 +01:00
100gle
3ead13f4b0 chore(format): fix the ruff checking issue 2023-10-02 13:16:31 +08:00
EstrellaXD
488ea0fd50 feat: add database migrate func. 2023-08-10 12:21:11 +08:00
EstrellaXD
1c4e8dc293 fix: old data support problem. 2023-08-07 20:14:45 +08:00
EstrellaXD
d768299c7f fix: fix bugs. 2023-08-06 16:04:38 +08:00
EstrellaXD
f99056c8d6 feat: add test for database and rss engine. 2023-08-05 20:19:06 +08:00
EstrellaXD
80ea9ec657 feat: Complete RSS engine. 2023-08-04 19:02:29 +08:00
estrella
472a5093e9 refactor: database and rss engine 2023-08-03 14:16:52 +08:00