refactor: split modules and harden scraping workflows

This commit is contained in:
ShukeBta
2026-06-24 11:59:18 +08:00
parent efca3cbe69
commit 192f35d9fa
470 changed files with 47957 additions and 33839 deletions
+16
View File
@@ -25,6 +25,7 @@ type ExternalMediaResult struct {
DoubanID string `json:"douban_id,omitempty"`
TheTVDBID string `json:"thetvdb_id,omitempty"`
SubscribeKeyword string `json:"subscribe_keyword"`
SubscribeAliases []string `json:"subscribe_aliases,omitempty"`
TotalEpisodes int `json:"total_episodes,omitempty"`
DownloadedEpisodes int `json:"downloaded_episodes,omitempty"`
LocalMediaCount int `json:"local_media_count,omitempty"`
@@ -67,6 +68,7 @@ func SearchExternalMedia(ctx context.Context, query string, year int, mediaType
TMDbID: m.TMDbID,
BangumiID: m.BangumiID,
SubscribeKeyword: buildSubscribeKeyword(m.Title, m.Year),
SubscribeAliases: buildSubscribeAliases(m.Title, m.OriginalName, m.Year),
TotalEpisodes: totalEpisodes,
Languages: m.Languages,
Countries: m.Countries,
@@ -107,6 +109,7 @@ func SearchExternalMedia(ctx context.Context, query string, year int, mediaType
Rating: m.Rating,
DoubanID: m.DoubanID,
SubscribeKeyword: buildSubscribeKeyword(m.Title, yearValue),
SubscribeAliases: buildSubscribeAliases(m.Title, "", yearValue),
})
}
}
@@ -116,12 +119,25 @@ func SearchExternalMedia(ctx context.Context, query string, year int, mediaType
func buildSubscribeKeyword(title string, year int) string {
title = strings.TrimSpace(title)
if title == "" {
return ""
}
if year > 0 {
return fmt.Sprintf("%s %d", title, year)
}
return title
}
func buildSubscribeAliases(title, originalName string, year int) []string {
values := []string{
title,
originalName,
buildSubscribeKeyword(title, year),
buildSubscribeKeyword(originalName, year),
}
return compactUniqueStrings(values...)
}
func normalizeDoubanType(doubanType, fallback string) string {
doubanType = strings.ToLower(strings.TrimSpace(doubanType))
switch doubanType {