How yangpz005/mpv-to-bgm works
mpv-to-bgm synchronizes anime playback with a user’s Bangumi watched-episode list. The principal workflow starts with a playback file and progress, filters below-threshold or ignored files, parses title/season/episode, resolves a Bangumi subject through manual mappings, aliases, cache, Bangumi search, and AniList fallback, then finds the episode and marks it watched. The graph also includes CLI mapping and OAuth setup. The README documents the mpv integration and matching capabilities; some wiring details for the Lua plugin and unsampled matching stages are therefore shown only where documentation supports them.
Main entry points: main.py Sync and CLI · mapper.py Title mapper · bgm_client.py Bangumi client · config.py Config manager
Components 15
Playback intake
- mpv Lua plugin
scripts/mpv-to-bgm/main.lua - Sync and CLI
scripts/mpv-to-bgm/src/main.py - Filename parser
scripts/mpv-to-bgm/src/parser.py
Title matching
- Title mapper
scripts/mpv-to-bgm/src/mapper.py - Mappings and aliases
scripts/mpv-to-bgm - Mapping and sync cache
scripts/mpv-to-bgm/src/mapper.py - AniList client
scripts/mpv-to-bgm/src/anilist_client.py
Bangumi sync
- Bangumi client
scripts/mpv-to-bgm/src/bgm_client.py
Configuration and auth
- Config manager
scripts/mpv-to-bgm/src/config.py - OAuth authorization
scripts/mpv-to-bgm/src/authorize.py - Configuration file
scripts/mpv-to-bgm/src/config.py
Other components
- mpv playback
- Bangumi API
- AniList API
- Bangumi OAuth
Connections 18
- mpv playback → mpv Lua plugin: plays video
- mpv Lua plugin → Sync and CLI: starts sync
- Sync and CLI → Config manager: loads settings
- Sync and CLI → Filename parser: parses filename
- Sync and CLI → Title mapper: resolves title
- Sync and CLI → Bangumi client: finds episode
- Sync and CLI → Bangumi client: marks watched
- Sync and CLI → Title mapper: manages mappings
- Title mapper → Mappings and aliases: loads mappings
- Title mapper → Mapping and sync cache: reads and writes
- Title mapper → Bangumi client: searches subjects
- Title mapper → AniList client: searches fallback
- Bangumi client → Bangumi API: searches and updates
- AniList client → AniList API: searches titles
- OAuth authorization → Bangumi OAuth: exchanges code
- OAuth authorization → Config manager: loads and saves tokens
- Config manager → Configuration file: reads and writes
- Bangumi client → Config manager: persists refreshed tokens