fix issue 51 library reclassify regressions

This commit is contained in:
ShukeBta
2026-06-27 00:40:39 +08:00
parent 4c839b3f4e
commit 8d0aa2b589
15 changed files with 371 additions and 35 deletions
+26
View File
@@ -156,6 +156,7 @@ func (s *ScraperService) applyProviderMatchWithOptions(ctx context.Context, m *m
if len(match.Languages) > 0 {
updates["languages"] = strings.Join(match.Languages, ",")
}
applyScrapeMediaTypeResets(updates, match)
if err := s.repo.DB.Model(&model.Media{}).Where("id = ?", m.ID).
Updates(updates).Error; err != nil {
@@ -188,3 +189,28 @@ func (s *ScraperService) applyProviderMatchWithOptions(ctx context.Context, m *m
})
return nil
}
func applyScrapeMediaTypeResets(updates map[string]any, match *Match) {
if updates == nil || match == nil {
return
}
switch normalizeOrganizeMediaType(match.MediaType) {
case "movie", "adult":
updates["season_num"] = 0
updates["episode_num"] = 0
updates["episode_title"] = ""
updates["series_id"] = ""
if match.TMDbID <= 0 {
updates["tm_db_id"] = 0
}
if match.BangumiID <= 0 {
updates["bangumi_id"] = 0
}
if strings.TrimSpace(match.DoubanID) == "" {
updates["douban_id"] = ""
}
if strings.TrimSpace(match.TheTVDBID) == "" {
updates["thetvdb_id"] = ""
}
}
}