mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 13:56:37 +08:00
refactor: split modules and harden scraping workflows
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user