mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-02 20:26:36 +08:00
fix: show latest discover posters
This commit is contained in:
@@ -25,9 +25,12 @@ type discoverSectionDef struct {
|
||||
var discoverSectionCatalog = []discoverSectionDef{
|
||||
{Key: "tmdb_trending_day", Label: "TMDb 今日趋势", Provider: "tmdb"},
|
||||
{Key: "tmdb_trending_week", Label: "TMDb 本周热门", Provider: "tmdb"},
|
||||
{Key: "tmdb_latest_movie", Label: "TMDb 最新电影", Provider: "tmdb"},
|
||||
{Key: "tmdb_latest_tv", Label: "TMDb 最新剧集", Provider: "tmdb"},
|
||||
{Key: "tmdb_popular_movie", Label: "TMDb 热门电影", Provider: "tmdb"},
|
||||
{Key: "tmdb_popular_tv", Label: "TMDb 热门剧集", Provider: "tmdb"},
|
||||
{Key: "tmdb_top_rated_movie", Label: "TMDb 高分电影", Provider: "tmdb"},
|
||||
{Key: "tmdb_upcoming_movie", Label: "TMDb 即将上映", Provider: "tmdb"},
|
||||
{Key: "douban_hot_movie", Label: "豆瓣热门电影", Provider: "douban"},
|
||||
{Key: "douban_hot_tv", Label: "豆瓣热门剧集", Provider: "douban"},
|
||||
{Key: "douban_top_movie", Label: "豆瓣高分电影", Provider: "douban"},
|
||||
@@ -94,7 +97,7 @@ func enabledDiscoverSections(ctx context.Context, svc *service.Container) []disc
|
||||
}
|
||||
|
||||
func defaultDiscoverSectionKeys(ctx context.Context, svc *service.Container) []string {
|
||||
preferred := []string{"tmdb_trending_day", "douban_hot_movie", "douban_hot_tv", "bangumi_calendar"}
|
||||
preferred := []string{"tmdb_trending_day", "tmdb_latest_movie", "tmdb_latest_tv", "douban_hot_movie", "douban_hot_tv", "bangumi_calendar"}
|
||||
enabled := map[string]struct{}{}
|
||||
for _, section := range enabledDiscoverSections(ctx, svc) {
|
||||
enabled[section.Key] = struct{}{}
|
||||
@@ -124,7 +127,7 @@ func discoverSectionProvider(key string) string {
|
||||
}
|
||||
}
|
||||
switch key {
|
||||
case "trending_day", "trending_week", "popular_movie", "popular_tv", "top_rated_movie", "upcoming_movie":
|
||||
case "trending_day", "trending_week", "latest_movie", "latest_tv", "popular_movie", "popular_tv", "top_rated_movie", "upcoming_movie":
|
||||
return "tmdb"
|
||||
default:
|
||||
return ""
|
||||
@@ -144,8 +147,8 @@ func discoverProviderEnabled(ctx context.Context, svc *service.Container, provid
|
||||
|
||||
func discoverSectionItems(ctx context.Context, svc *service.Container, k string) ([]service.ExternalMediaResult, error) {
|
||||
switch k {
|
||||
case "tmdb_trending_day", "tmdb_trending_week", "tmdb_popular_movie", "tmdb_popular_tv", "tmdb_top_rated_movie",
|
||||
"trending_day", "trending_week", "popular_movie", "popular_tv", "top_rated_movie", "upcoming_movie":
|
||||
case "tmdb_trending_day", "tmdb_trending_week", "tmdb_latest_movie", "tmdb_latest_tv", "tmdb_popular_movie", "tmdb_popular_tv", "tmdb_top_rated_movie", "tmdb_upcoming_movie",
|
||||
"trending_day", "trending_week", "latest_movie", "latest_tv", "popular_movie", "popular_tv", "top_rated_movie", "upcoming_movie":
|
||||
return svc.Discover.TMDbSection(ctx, k)
|
||||
case "douban_hot_movie", "douban_hot_tv", "douban_top_movie":
|
||||
if svc.Douban == nil {
|
||||
|
||||
@@ -65,3 +65,16 @@ func TestDefaultDiscoverSectionKeysSkipDisabledProviders(t *testing.T) {
|
||||
t.Fatal("default keys should keep enabled providers")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultDiscoverSectionKeysIncludeLatestTMDbRails(t *testing.T) {
|
||||
keys := defaultDiscoverSectionKeys(t.Context(), &service.Container{})
|
||||
keySet := map[string]struct{}{}
|
||||
for _, key := range keys {
|
||||
keySet[key] = struct{}{}
|
||||
}
|
||||
for _, key := range []string{"tmdb_latest_movie", "tmdb_latest_tv"} {
|
||||
if _, ok := keySet[key]; !ok {
|
||||
t.Fatalf("default discover keys should include %q: %v", key, keys)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +178,10 @@ func tmdbDiscoverPath(key string) string {
|
||||
return "/trending/movie/day"
|
||||
case "tmdb_trending_week", "trending_week":
|
||||
return "/trending/movie/week"
|
||||
case "tmdb_latest_movie", "latest_movie":
|
||||
return "/movie/now_playing"
|
||||
case "tmdb_latest_tv", "latest_tv":
|
||||
return "/tv/on_the_air"
|
||||
case "tmdb_popular_movie", "popular_movie":
|
||||
return "/movie/popular"
|
||||
case "tmdb_popular_tv", "popular_tv":
|
||||
|
||||
@@ -83,6 +83,21 @@ func TestDiscoverWarmArtworkNoImageProxyIsNoop(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTMDbDiscoverPathIncludesLatestSections(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"tmdb_latest_movie": "/movie/now_playing",
|
||||
"latest_movie": "/movie/now_playing",
|
||||
"tmdb_latest_tv": "/tv/on_the_air",
|
||||
"latest_tv": "/tv/on_the_air",
|
||||
"tmdb_upcoming_movie": "/movie/upcoming",
|
||||
}
|
||||
for key, want := range cases {
|
||||
if got := tmdbDiscoverPath(key); got != want {
|
||||
t.Fatalf("tmdbDiscoverPath(%q) = %q, want %q", key, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func waitForDiscoverArtworkCache(t *testing.T, calls *int32, wantCalls int32, cachePath, raw string) {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(2 * time.Second)
|
||||
|
||||
Reference in New Issue
Block a user