Skip to content

refactor(db): 引入统一媒体数据库 - #869

Merged
MCDFsteve merged 19 commits into
AimesSoft:mainfrom
Kuuhaku31:refactor/nipaplay-db
Sep 14, 2026
Merged

MCDFsteve merged 19 commits into
AimesSoft:mainfrom
Kuuhaku31:refactor/nipaplay-db

Conversation

@Kuuhaku31

@Kuuhaku31 Kuuhaku31 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Important

本 PR 根据 #867 的设计思路, 仅引入了新的统一的媒体数据库架构, 并未对现有逻辑进行任何修改.

最终的详细设计请参考本次 PR 新增的文档: docs/DATA_STORAGE.md.

Summary

  • 添加 DatabaseService 掌管新数据库交互, 同步添加相关模型类和 sql 文件
    lib/services/anime_info/anime_info_service.dart
  • 添加 AnimeInfoService 统一调度: 数据库, API, JSON 缓存文件, 进行番剧信息获取和持久化
    lib/services/anime_info/anime_info_service.dart
  • 添加相关测试

下一步计划

保持旧数据库不变的情况下逐步把新数据库功能接入业务代码.

会在设置里添加一个 "开启新版数据库系统" 的实验选项, 打开后用户数据同步保存到两方, 同时程序优先使用新数据库的数据.

Related Issue

@Kuuhaku31 Kuuhaku31 changed the title refactor(db) refactor(db): 引入统一媒体数据库 Aug 20, 2026
@Kuuhaku31

Copy link
Copy Markdown
Contributor Author

当前进度

1. 数据库重构设计大体完成

根据 issue #867 的设计思路, 彻底重构底层数据库架构.

但是目前还没有替换现有的观看历史数据库, 而是新增了一套独立的 SQLite 数据层,
DatabaseServiceDatabaseSql 负责数据库交互.

  • lib/services/database/database_service.dart
  • lib/services/database/sql.dart

新的数据模型以内部统一的 Anime 和 Episode 作为跨数据源实体, 关联 Dandanplay 和 Bangumi 数据实体.

2. 新增的 AnimeInfoService 作为业务逻辑层

AnimeInfoService 协调 API 数据获取与数据库写入.
当外部需要获取某部文件关联的剧集, 弹幕信息时, 只需访问 AnimeInfoService,
它会决策用数据库数据, 还是从 API 获取最新数据.

  • lib/services/anime_info_service.dart

3. 补充测试和文档

用来验证新数据库以及主要数据流程, 包括:

  • 文件路径 → Hash → 数据库
  • 文件 Hash → Dandanplay Episode → 弹幕
  • Dandanplay/Bangumi Anime → Package → 数据库

本次 PR 预计合并的工作

重点是建立新的媒体库数据模型, 数据库基础设施以及从外部 API 到数据库的数据同步原型.
暂时不接入现有的数据库系统, 也不修改现有的业务逻辑.

@Kuuhaku31
Kuuhaku31 marked this pull request as ready for review August 29, 2026 04:00
@Kuuhaku31
Kuuhaku31 requested a review from a team as a code owner August 29, 2026 04:00

@FurudeRika123 FurudeRika123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comprehensive refactor and the detailed documentation in docs/DATA_STORAGE.md!

Before we can proceed with a full review and merge, please note that the CI check (PR Validation / Analyze and Test) is currently failing on the latest commit. Could you please run flutter analyze and flutter test locally to check for any analysis errors, lint warnings, or failing tests and resolve them?

Once the CI pipeline passes green, we will proceed with the detailed code review. Thanks again for your contribution!

@Kuuhaku31
Kuuhaku31 marked this pull request as draft August 29, 2026 15:03
@Kuuhaku31
Kuuhaku31 marked this pull request as ready for review August 30, 2026 03:44
@Kuuhaku31
Kuuhaku31 force-pushed the refactor/nipaplay-db branch from d26e8ae to d4b44e6 Compare August 30, 2026 03:53
@MCDFsteve
MCDFsteve merged commit c835782 into AimesSoft:main Sep 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants