From 68c6e0261867728b1fe2c847b5403cd6dfc009ad Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Fri, 4 Apr 2025 16:39:10 -0400 Subject: [PATCH] ALWAYS_SKIP_IDS -> ALWAYS_SKIP_MAL_IDS --- README.md | 4 ++-- main.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a0e6e20..0e926c3 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ curl "http://localhost:3333/anime?type=tv&status=airing&order_by=popularity&sort ## Environment One configuration environment variable is supported: -- `ALWAYS_SKIP_IDS`: Comma-separated list of MyAnimeList IDs to always skip. These do not count towards the return limit. +- `ALWAYS_SKIP_MAL_IDS`: Comma-separated list of MyAnimeList IDs to always skip. These do not count towards the return limit. ## Docker Compose ```yaml @@ -31,7 +31,7 @@ services: ports: - 3333:3333 environment: - - ALWAYS_SKIP_IDS=12345,67890 # Comma-separated + - ALWAYS_SKIP_MAL_IDS=12345,67890 # Comma-separated restart: unless-stopped ``` diff --git a/main.go b/main.go index 71a38df..015b98d 100644 --- a/main.go +++ b/main.go @@ -44,24 +44,24 @@ func main() { log.Println("Building Anime ID Associations...") var malToTvdb = new(ConcurrentMap) buildIdMap(malToTvdb) - permaSkipStr := os.Getenv("ALWAYS_SKIP_IDS") - permaSkipIds := strings.Split(permaSkipStr, ",") - if permaSkipStr != "" { - log.Printf("Always skipping: %v\n", permaSkipIds) + permaSkipMalStr := os.Getenv("ALWAYS_SKIP_MAL_IDS") + permaSkipMalIds := strings.Split(permaSkipMalStr, ",") + if permaSkipMalStr != "" { + log.Printf("Always skipping: %v\n", permaSkipMalIds) } - http.HandleFunc("/anime", handleAnimeSearch(malToTvdb, permaSkipIds)) + http.HandleFunc("/anime", handleAnimeSearch(malToTvdb, permaSkipMalIds)) log.Println("Listening on :3333") log.Fatal(http.ListenAndServe(":3333", nil)) } -func handleAnimeSearch(malToTvdb *ConcurrentMap, permaSkipIds []string) func(w http.ResponseWriter, r *http.Request) { +func handleAnimeSearch(malToTvdb *ConcurrentMap, permaSkipMalIds []string) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { log.Printf("%s %s?%s", r.Method, r.URL.Path, r.URL.RawQuery) if time.Since(lastBuiltAnimeIdList) > 24*time.Hour { log.Println("Anime ID association table expired, building new table...") buildIdMap(malToTvdb) } - search, err := getAnimeSearch(malToTvdb, permaSkipIds, r) + search, err := getAnimeSearch(malToTvdb, permaSkipMalIds, r) if err != nil { w.WriteHeader(500) } else { @@ -70,7 +70,7 @@ func handleAnimeSearch(malToTvdb *ConcurrentMap, permaSkipIds []string) func(w h } } -func getAnimeSearch(malToTvdb *ConcurrentMap, permaSkipIds []string, r *http.Request) (string, error) { +func getAnimeSearch(malToTvdb *ConcurrentMap, permaSkipMalIds []string, r *http.Request) (string, error) { q := r.URL.Query() limit, err := strconv.Atoi(q.Get("limit")) @@ -108,7 +108,7 @@ func getAnimeSearch(malToTvdb *ConcurrentMap, permaSkipIds []string, r *http.Req log.Printf("MyAnimeList ID %d (%s a.k.a. %s) is a duplicate, skipping...\n", item.MalId, item.Title, item.TitleEnglish) continue } - if slices.Contains(permaSkipIds, strconv.Itoa(item.MalId)) { + if slices.Contains(permaSkipMalIds, strconv.Itoa(item.MalId)) { log.Printf("MyAnimeList ID %d (%s a.k.a. %s) is set to always skip, skipping...\n", item.MalId, item.Title, item.TitleEnglish) continue }