mirror of
https://github.com/gabehf/sonarr-anime-importer.git
synced 2026-03-08 23:18:14 -07:00
ALWAYS_SKIP_IDS -> ALWAYS_SKIP_MAL_IDS
This commit is contained in:
parent
ae664ab6b3
commit
68c6e02618
2 changed files with 11 additions and 11 deletions
|
|
@ -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
|
||||
|
||||
```
|
||||
|
|
|
|||
18
main.go
18
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue