logic/envvars.go

67 lines
2.5 KiB
Go
Raw Permalink Normal View History

2023-01-13 10:21:45 +01:00
package logic
import (
2023-01-13 10:39:59 +01:00
"html/template"
"math"
2023-01-13 11:10:07 +01:00
"git.milar.in/milarin/anilist"
2023-01-13 10:21:45 +01:00
"git.milar.in/milarin/envvars/v2"
"git.milar.in/nyaanime/model"
)
var (
2023-01-13 11:10:07 +01:00
AnilistUsername = envvars.String("ANILIST_USERNAME", "username")
AnilistAccessToken = envvars.String("ANILIST_TOKEN", "")
StoragePath = envvars.String("STORAGE_PATH", "")
StorageUser = envvars.String("STORAGE_USERNAME", "")
StoragePass = envvars.String("STORAGE_PASSWORD", "")
2023-01-13 10:39:59 +01:00
AnimePath = envvars.String("ANIME_PATH", "")
2023-01-16 00:45:58 +01:00
AnimeEpFilepathPatternStr = envvars.String("EPISODE_FILEPATH_PATTERN", `{{.Anime.Title.UserPreferred}}/{{.Anime.Title.UserPreferred}} Episode {{.Episode}}.{{.Ext}}`)
AnimeEpFilepathPattern = template.Must(template.New("EPISODE_FILEPATH_PATTERN").Parse(AnimeEpFilepathPatternStr))
2023-01-13 10:39:59 +01:00
// essential torrent properties
MaxResolution = envvars.Object("MAX_RESOLUTION", model.Resolution4K, model.ParseResolution)
MinResolution = envvars.Object("MIN_RESOLUTION", model.ResolutionHD, model.ParseResolution)
EssentialLanguages = envvars.StringSlice("ESSENTIAL_LANGUAGES", "|", []string{})
EssentialSubtitles = envvars.StringSlice("ESSENTIAL_SUBTITLES", "|", []string{})
MaxSeeders = envvars.Int("MAX_SEEDERS", math.MaxInt)
MinSeeders = envvars.Int("MIN_SEEDERS", 0)
MaxLeechers = envvars.Int("MAX_LEECHERS", math.MaxInt)
MinLeechers = envvars.Int("MIN_LEECHERS", 0)
MaxDownloads = envvars.Int("MAX_DOWNLOADS", math.MaxInt)
MinDownloads = envvars.Int("MIN_DOWNLOADS", 0)
TrustedOnly = envvars.Bool("TRUSTED_ONLY", false)
2023-01-13 10:21:45 +01:00
// preferred torrent properties
PreferredLanguages = ParsePreferredStringProps(envvars.StringSlice("PREFERRED_LANGUAGES", "|", []string{}))
PreferredSubtitles = ParsePreferredStringProps(envvars.StringSlice("PREFERRED_SUBTITLES", "|", []string{}))
PreferredResolutions = ParsePreferredProps(envvars.StringSlice("PREFERRED_RESOLUTIONS", "|", []string{}), model.ParseResolution)
2023-01-13 10:39:59 +01:00
2023-01-13 11:10:07 +01:00
AnimeStatuses = envvars.ObjectSlice("ANIME_STATUSES", ",", []anilist.MediaListStatus{
anilist.MediaListStatusCurrent,
anilist.MediaListStatusPlanning,
}, ParseMediaListStatus)
2023-01-13 10:39:59 +01:00
/*
TODO
better idea? implementation in torrent_sort.go (sort.Slice)
PreferredTorrents = envvars.StringSlice("PREFERRED_TORRENTS", []string{"seeders", "subtitles", "languages", "downloads"})
old idea?
PreferMoreLanguages = envvars.Bool("PREFERER_MORE_LANGUAGES", false)
PreferMoreSubtitles = envvars.Bool("PREFERER_MORE_SUBTITLES", false)
PreferMoreSeeders = envvars.Bool("PREFERER_MORE_SEEDERS", false)
PreferMoreDownloads = envvars.Bool("PREFERER_MORE_DOWNLOADS", false)
*/
2023-01-13 10:21:45 +01:00
)