296 Commits

Author SHA1 Message Date
Estrella Pan
f4a83d10f8 chore: bump version to 3.2.3-beta.1 2026-01-28 08:21:50 +01:00
EstrellaXD
b0c00598a5 chore: bump version to 3.2.2 2026-01-27 11:05:36 +01:00
EstrellaXD
f06ed41c0d chore: bump version to 3.2.1 2026-01-27 10:40:35 +01:00
Estrella Pan
7e9f3a707a fix(renamer): only log rename operations that actually succeed
Previously, the rename log message was printed before checking if the
qBittorrent API call succeeded. This caused log spam when rename
operations failed (e.g., due to 409 conflicts or network errors) since
the same file would be attempted again on the next cycle.

Now the log message is only printed after confirming the rename
succeeded, reducing noise in the logs.

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-27 07:06:18 +01:00
Estrella Pan
24f1f72941 fix(renamer): improve episode offset warning messages (#962)
The warning "Episode offset 0 would result in negative episode" was
misleading and caused log spam. The actual issue was either:
1. Parsed episode was 0 or negative (parsing failure or special episode)
2. A negative offset would make a valid episode negative

Changes:
- Differentiate between parsing issues vs offset issues in log messages
- Use debug level for parsed episode issues (likely special episodes)
- Keep warning level only for actual offset problems
- Include original episode value in warning for better debugging
- Handle edge case where parsed episode is 0 by falling back to 1

Fixes #962

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-27 06:46:14 +01:00
Estrella Pan
3146029d0b fix: add socksio dependency to support SOCKS proxy (#961)
When users have a SOCKS proxy configured (via HTTP_PROXY or ALL_PROXY
environment variables), httpx's AsyncClient automatically tries to use
it but fails without the socksio package installed.

Changed httpx dependency from httpx>=0.25.0 to httpx[socks]>=0.25.0 to
include the socksio package as an extra dependency.

Fixes #961

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-27 06:42:03 +01:00
Estrella Pan
d288994916 fix(test): mock VERSION in setup test to test non-dev config check logic 2026-01-26 21:03:34 +01:00
Estrella Pan
9b27621861 feat(setup): improve dev mode support for setup wizard testing
- Allow setup in dev mode even if settings differ from defaults
- Add mock downloader type for development testing
- Only check sentinel file in dev mode for need_setup status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 20:11:48 +01:00
EstrellaXD
47a10d5828 fix: suppress verbose httpx HTTP request logs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:08:29 +01:00
EstrellaXD
359b3e5253 fix: resolve all deprecation warnings
Pydantic V2:
- Replace @validator with @field_validator in models/config.py
- Replace .dict() with .model_dump() in Config, Settings, and BangumiDatabase
- Replace .parse_obj() with .model_validate() in Settings and tests
- Replace Field(example=) with Field(json_schema_extra=) in response models

Datetime:
- Replace datetime.utcnow() with datetime.now(timezone.utc) in jwt.py
- Update factories.py to use timezone-aware datetime

FastAPI:
- Migrate from deprecated @router.on_event() to lifespan context manager
- Move startup/shutdown handlers from program.py to main.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:34:19 +01:00
EstrellaXD
7b5c8d9ac5 chore: upgrade Python version to 3.13
- Update requires-python to >=3.13 in pyproject.toml
- Update ruff and black target versions to py313
- Update Dockerfile to use python:3.13-alpine
- Add explicit Python 3.13 setup in CI workflow
- Regenerate uv.lock for Python 3.13

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:30:25 +01:00
EstrellaXD
f22f5c657f fix(test): correct TypeScript types in frontend test mocks
- Use RSS type instead of non-existent RSSItem/RSSResponse
- Add expire field to mockLoginSuccess
- Replace offset with episode_offset/season_offset in mockBangumiAPI
- Add needs_review_reason field to mockBangumiAPI
- Add missing RSS fields (connection_status, last_checked_at, last_error)
- Fix generic types in test utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:24:31 +01:00
EstrellaXD
a137b54b85 test: add comprehensive API tests for backend and frontend
Backend:
- Add API test files for auth, program, downloader, config, log, bangumi extended, search, and passkey endpoints
- Update conftest.py with new fixtures (app, authed_client, unauthed_client, mock_program, mock_webauthn, mock_download_client)
- Update factories.py with make_config and make_passkey functions

Frontend:
- Setup vitest testing infrastructure with happy-dom environment
- Add test setup file with mocks for axios, router, i18n, localStorage
- Add mock API data for testing
- Add tests for API logic, store logic, hooks, and basic components
- Add @vue/test-utils and happy-dom dev dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:20:39 +01:00
EstrellaXD
4e2a22aba5 chore: bump version to 3.2.0-beta.13
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:56:49 +01:00
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
0c8ebb70a3 fix(error-handling): replace bare except clauses with specific exceptions
- qb_downloader.py: catch httpx network errors in logout() and rename_file()
- user.py: log exception details when querying users table fails
- download_client.py: log exception when category creation fails
- title_parser.py: catch specific exceptions (ValueError, AttributeError, TypeError)
  instead of broad Exception in raw_parser()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:51:44 +01:00
EstrellaXD
d6e89f62ed perf(database): optimize N+1 queries and add caching
- Replace N individual _is_duplicate() calls with single batch SELECT query
  in add_all() method, reducing database round-trips
- Replace O(n*m) nested loop in match_list() with compiled regex alternation
  pattern for faster torrent-to-bangumi matching
- Add LRU cache (512 entries) to torrent_parser() to avoid redundant regex
  parsing for the same torrent paths
- Extend bangumi search_all() cache TTL from 60s to 300s (5 minutes)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:30:16 +01:00
EstrellaXD
ebd58531b5 fix(test): add missing DEV_AUTH_BYPASS constant for test mocking
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:06:13 +01:00
EstrellaXD
08a71b877c chore: bump version to 3.2.0-beta.12
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:02:19 +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
EstrellaXD
95165da3b6 fix(offset): apply season_offset to folder path and update RSS rules
When user sets season_offset, the save path now reflects the adjusted season:
- _gen_save_path() uses (season + season_offset) for folder name
- Files saved directly to correct folder (e.g., Season 2 instead of Season 1)
- update_rule() now updates qBittorrent RSS rule's savePath when offset changes
- Existing torrents are moved to the new location

Renamer changes:
- gen_path() no longer double-applies season_offset (folder already has it)
- Season number taken directly from folder name
- Added path normalization for better save_path matching
- Added debug logging for offset lookup

Torrent name matching (title_raw) remains primary fallback for finding bangumi.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:39:01 +01:00
Estrella Pan
bfb94145cb test(renamer): add comprehensive tests for offset lookup functionality
Add tests covering:
- _parse_bangumi_id_from_tags: tag parsing with various formats
- gen_path with offsets: episode/season offset application
- _lookup_offsets: multi-tier lookup (qb_hash, tags, name, path)
- TorrentDatabase hash lookup methods (search_by_qb_hash, search_by_url, update_qb_hash)

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:24:23 +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
12ac30c76a fix(core): prevent duplicate startup logo from nested router lifespan events
FastAPI's merged_lifespan mechanism triggers lifespan events for each
nested router layer. Since program_router is included in v1, which is
included in app, the startup handler was being called 3 times.

Added _startup_done flag to ensure Program.startup() only executes once.

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 07:28:48 +01:00
Estrella Pan
93d2f2e7d2 chore: bump version to 3.2.0-beta.11
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 23:15:52 +01:00
Estrella Pan
a0a21a71e5 feat(webui): add search provider settings panel
- Add config-search-provider.vue component for managing search sources
- Support CRUD operations for custom search providers
- Default providers (mikan, nyaa, dmhy) cannot be deleted
- URL template validation ensures %s placeholder is present
- Add backend API endpoints GET/PUT /search/provider/config
- Add i18n translations for zh-CN and en

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 22:27:33 +01:00
XYenon
3695452fb7 Fix parser (#877)
Thanks for the fix! The improved regex pattern will help parse more anime titles correctly. Closes #876 and #924. 🎉
2026-01-25 22:12:43 +01:00
Wu Ying Ying
0385129f5d fix: None official_title in bangumi stopping rss parsing (#866)
Thanks for catching this edge case! This defensive fix prevents crashes when parsing RSS items with empty titles. 🎉
2026-01-25 22:12:41 +01:00
Leohearts
61c071e035 [fix] better json parsing in openai.py (#913)
Thanks for the contribution\! This fix helps users who use alternative GPT APIs like Moonshot that don't support structured output mode. 🎉
2026-01-25 22:12:38 +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
9790dce06c fix(passkey): add data field to ResponseModel for passkey login
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:37:53 +01:00
Estrella Pan
c044b65fef chore: bump version to 3.2.0-beta.9
Fix TypeScript error in ab-search-bar.vue and include pending changes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:29:12 +01:00
Estrella Pan
f1fb4d7926 chore: bump version to 3.2.0-beta.8 2026-01-25 19:25:06 +01:00
Estrella Pan
22870b8ae3 feat(auth): support usernameless passkey login (discoverable credentials)
- Change resident key requirement from PREFERRED to REQUIRED during registration
- Add discoverable authentication options (empty allowCredentials)
- Add verify_discoverable_authentication method in WebAuthn service
- Update auth strategy to lookup user from credential when username not provided
- Make username optional in frontend passkey login flow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:23:39 +01:00
Estrella Pan
9e6a528e57 fix(search): resolve multiple issues in search and subscription flow
- Fix axios interceptor error when response.data is undefined by adding
  optional chaining (?.msg_en, ?.msg_zh)
- Fix XML parsing crash in backend by catching ParseError exceptions
- Remove brotli (br) from Accept-Encoding header to fix mikan RSS fetch
  issues (httpx doesn't auto-decompress brotli)
- Fix search card click event not triggering confirmation modal by
  changing from native 'click' to custom 'select' event with typed payload
- Add NMessageProvider to App.vue to fix useMessage() outside setup error
- Replace structuredClone with JSON.parse/stringify in confirm modal
  to handle Vue reactive Proxy objects

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 17:33:46 +01:00
Estrella Pan
da6e578404 fix(network): improve torrent fetch reliability and error handling
- Add browser-like headers and full Chrome User-Agent to avoid Cloudflare blocking
- Use appropriate Accept headers for torrent files (application/x-bittorrent)
- Increase timeouts (connect: 5s→10s, read: 10s→30s) for slow responses
- Filter out None values from failed torrent fetches before sending to qBittorrent
- Add try-catch around add_torrents to prevent request crashes
- Improve logging from DEBUG to WARNING level for better visibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 14:11:11 +01:00
Estrella Pan
6ce3f92c74 chore: bump version to 3.2.0-beta.7 2026-01-25 11:50:32 +01:00
Estrella Pan
8e7e8933e4 fix(downloader): add retry logic for transient network errors in add_torrents
Handles httpx.ReadError and other network exceptions when adding torrents
to qBittorrent by retrying up to 3 times with a 2-second delay.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:47:26 +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
683e272b4d fix(core): add max retry for downloader connection check
Prevents startup from hanging indefinitely when downloader is
unreachable (e.g., due to proxy configuration). After 10 retries
(~5 min), program continues with an error log instead of blocking.

Fixes #955 (comment)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:58:55 +01:00
Estrella Pan
5064d42d59 chore: bump version to 3.2.0-beta.6
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:48:29 +01:00
Estrella Pan
ecd7914f22 fix(db): prevent duplicate bangumi rules in add_all method
- Add _is_duplicate() helper to check by (title_raw, group_name)
- Fix add_all() to skip existing records and deduplicate within batch
- Improve add() to use same deduplication logic

feat(ui): calendar page grouping and accessibility improvements

- Calendar page now groups bangumi by title+season (same as main page)
- Add rule selection popup for grouped bangumi with multiple rules
- Add skeleton loading animation on bangumi list page
- Fix popup z-index layering with CSS variable system
- Improve accessibility: 44px touch targets, focus-visible states, aria-labels
- Add i18n translations for rule selection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:38:16 +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
cba4988e52 perf: comprehensive performance optimization for backend and frontend
Backend: shared HTTP connection pool, concurrent RSS/torrent/notification
operations, TMDB/Mikan result caching, database indexes, pre-compiled
regex, __slots__ on dataclasses, O(1) set-based dedup, frozenset lookups,
batch RSS enable/disable, asyncio.to_thread for blocking calls.

Frontend: shallowRef for large arrays, computed table columns, watch
instead of watchEffect, scoped style fix, typed emits, noImplicitAny,
useIntervalFn lifecycle management, shared useClipboard instance,
shallow clone for shared template objects.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 20:46:45 +01:00
Estrella Pan
929a88c343 test: add comprehensive test suite for core business logic
Cover RSS engine, downloader, renamer, auth, notifications, search,
config, API endpoints, and end-to-end integration flows. When all
210 tests pass, the program's key behavioral contracts are verified.

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:59:18 +01:00
Estrella Pan
9ebf469539 chore: bump version to 3.2.0-beta.4
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:29:08 +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