Documentation
¶
Overview ¶
Package cfg used for process configuration
Package cfg used for process configuration
Index ¶
- Variables
- func GenUsedFlagMap() map[string]bool
- func GetOptionTime(options *str.Options) string
- func GetOutputForModule(options *str.Options) string
- func IsValidConfigType(allowedTypes []string, userType string) bool
- func IsValidConfigTypeSlice(allowedElements []string, userElements str.Slice) bool
- func OptionsFromConfig(fs afero.Fs, config *Config) (str.Options, error)
- func SyncOptionsFromFlags(fs afero.Fs, config *Config, flagMap map[string]string) (str.Options, error)
- func ValidateConfig(module string, config OptionsConfig) bool
- type Config
- func DefaultConfig() *Config
- func GetConfig(fs afero.Fs, configPath string) (*Config, error)
- func InitConfig(fs afero.Fs) (*Config, error)
- func MergeConfigs(defaultConfig *Config, fileConfig *Config, flagConfig map[string]string) (*Config, error)
- func ReadConfigFromFile(fs afero.Fs, filename string) (*Config, error)
- type OptionsConfig
Constants ¶
This section is empty.
Variables ¶
var ModuleActionConfig = map[string]OptionsConfig{ "comments:trending": { Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, }, "comments:recent": { Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, }, "movies:comments": { Type: []string{}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, }, "movies:lists": { Type: []string{"all", "personal", "official", "watchlists", "favorites"}, Sort: []string{"popular", "likes", "comments", "items", "added", "updated"}, }, "users:watched": { Type: []string{"movies", "shows"}, Sort: []string{}, }, "notes:notes": { Privacy: []string{"private", "friends", "public"}, }, "notes:note": { Privacy: []string{"private", "friends", "public"}, }, "notes:item": { Privacy: []string{"private", "friends", "public"}, }, "shows:comments": { Type: []string{}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, }, "shows:lists": { Type: []string{"all", "personal", "official", "watchlists", "favorites"}, Sort: []string{"popular", "likes", "comments", "items", "added", "updated"}, }, "shows:collection_progress": { Type: []string{"all", "personal", "official", "watchlists", "favorites"}, Sort: []string{"popular", "likes", "comments", "items", "added", "updated"}, }, "shows:watched_progress": { Type: []string{"all", "personal", "official", "watchlists", "favorites"}, Sort: []string{"popular", "likes", "comments", "items", "added", "updated"}, }, "seasons:comments": { Type: []string{}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, }, "seasons:lists": { Type: []string{"all", "personal", "official", "watchlists", "favorites"}, Sort: []string{"popular", "likes", "comments", "items", "added", "updated"}, }, "episodes:comments": { Type: []string{}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, }, "episodes:lists": { Type: []string{"all", "personal", "official", "watchlists", "favorites"}, Sort: []string{"popular", "likes", "comments", "items", "added", "updated"}, }, "sync:playback": { Type: []string{"movies", "episodes"}, Sort: []string{}, }, "sync:get_watched": { Type: []string{"movies", "shows", "episodes"}, Sort: []string{}, }, "sync:get_history": { Type: []string{"movies", "shows", "seasons", "episodes"}, Sort: []string{}, }, "sync:get_ratings": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, Rating: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, }, "sync:get_watchlist": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, Rating: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "sync:update_watchlist": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "sync:remove_watchlist": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "sync:get_favorites": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, Rating: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "sync:update_favorites": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "users:hidden_items": { Type: []string{"movie", "show", "season", "user"}, Section: []string{"calendar", "progress_watched", "progress_watched_reset", "progress_collected", "recommendations", "comments", "dropped"}, }, "users:likes": { Type: []string{"comments", "lists"}, }, "users:collection": { Type: []string{"movies", "shows"}, }, "users:comments": { Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, CommentType: []string{"all", "reviews", "shouts"}, IncludeReplies: []string{"true", "false", "only"}, }, "users:notes": { Type: []string{"all", "movies", "shows", "seasons", "episodes", "people", "history", "collection", "ratings"}, }, "users:update_list": { Privacy: []string{"private", "friends", "public"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "users:delete_list": { Privacy: []string{"private", "friends", "public"}, }, "users:list_items": { Type: []string{"movies", "shows", "seasons", "episodes", "persons"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "users:list_comments": { Type: []string{"movies", "shows", "seasons", "episodes", "persons"}, Sort: []string{"likes", "likes_30", "replies", "replies_30", "plays", "rating", "added"}, }, "users:list_report": { Reason: []string{"duplicate", "remove", "metadata", "adult", "language", "spam", "other"}, }, "users:history": { Type: []string{"movies", "shows", "seasons", "episodes"}, }, "users:ratings": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, }, "users:watchlist": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "users:watchlist_comments": { Sort: []string{"likes", "likes_30", "replies", "replies_30", "plays", "rating", "added"}, }, "users:favorites": { Type: []string{"movies", "shows", "seasons", "episodes", "all"}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, "users:favorites_comments": { Sort: []string{"likes", "likes_30", "replies", "replies_30", "plays", "rating", "added"}, }, }
ModuleActionConfig represents the configuration options depens on module:action key
var ModuleConfig = map[string]OptionsConfig{ "watchlist": { SearchIDType: []string{}, SearchType: []string{}, SearchField: []string{}, Type: []string{"movies", "shows", "episodes", "persons"}, Sort: []string{"rank", "added", "released", "title"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "collection": { SearchIDType: []string{}, SearchType: []string{}, SearchField: []string{}, Type: []string{"movies", "shows", "episodes", "persons"}, Sort: []string{"rank", "added", "released", "title"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "comments": { SearchIDType: []string{}, SearchType: []string{}, CommentType: []string{"all", "review", "shouts"}, SearchField: []string{}, Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Sort: []string{"rank", "added", "released", "title"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "history": { SearchIDType: []string{}, SearchType: []string{}, SearchField: []string{}, Type: []string{"movies", "shows", "episodes", "persons"}, Sort: []string{"rank", "added", "released", "title"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "lists": { SearchIDType: []string{}, SearchType: []string{}, SearchField: []string{}, Type: []string{"movies", "shows", "episodes", "persons"}, Sort: []string{"rank", "added", "released", "title"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "movies": { SearchIDType: []string{}, SearchType: []string{}, CommentType: []string{"all", "review", "shouts"}, SearchField: []string{}, Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Period: []string{"all", "daily", "weekly", "monthly"}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "people": { SearchIDType: []string{}, SearchType: []string{}, SearchField: []string{}, Type: []string{"movies", "shows", "episodes", "persons", "all", "personal", "official"}, Sort: []string{"rank", "added", "released", "title", "popular", "likes", "comments", "items", "added", "updated"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "search": { SearchIDType: []string{"trakt", "imdb", "tmdb", "tvdb"}, SearchType: []string{"movie", "show", "episode", "person", "list", "podcast", "podcast_episode"}, SearchField: []string{"title", "aliases", "biography", "description", "episode", "name", "overview", "people", "show", "tagline", "translations"}, Type: []string{"movies", "shows", "episodes", "persons", "all", "personal", "official"}, Sort: []string{"rank", "added", "released", "title", "popular", "likes", "comments", "items", "added", "updated"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "shows": { SearchIDType: []string{}, SearchType: []string{}, CommentType: []string{"all", "review", "shouts"}, SearchField: []string{}, Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Period: []string{"all", "daily", "weekly", "monthly"}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "seasons": { SearchIDType: []string{}, SearchType: []string{}, CommentType: []string{"all", "review", "shouts"}, SearchField: []string{}, Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Period: []string{"all", "daily", "weekly", "monthly"}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "episodes": { SearchIDType: []string{}, SearchType: []string{}, CommentType: []string{"all", "review", "shouts"}, SearchField: []string{}, Type: []string{"all", "movies", "shows", "seasons", "episodes", "lists"}, Period: []string{"all", "daily", "weekly", "monthly"}, Sort: []string{"newest", "oldest", "likes", "replies", "highest", "lowest", "plays"}, Format: []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"}, Action: []string{}, }, "users": { SearchIDType: []string{}, SearchType: []string{}, SearchField: []string{}, Type: []string{"movies", "shows"}, Sort: []string{}, Format: []string{}, Action: []string{}, }, "notes": { Privacy: []string{"private", "friends", "public"}, }, "sync": { Type: []string{"all", "movies", "shows"}, Rating: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, SortHow: []string{"asc", "desc"}, SortBy: []string{"rank", "added", "title", "released", "runtime", "popularity", "random", "percentage", "imdb_rating", "tmdb_rating", "rt_tomatometer", "rt_audience", "metascore", "votes", "imdb_votes", "tmdb_votes", "my_rating", "watched", "collected"}, }, }
ModuleConfig represents the configuration options for all modules
var SearchFieldConfig = map[string][]string{
"movie": {"title", "tagline", "overview", "people", "translations", "aliases"},
"show": {"title", "overview", "people", "translations", "aliases"},
"episode": {"title", "overview"},
"person": {"name", "biography"},
"list": {"name", "description"},
}
SearchFieldConfig represents the configuration options for search_field depens on type
Functions ¶
func GetOptionTime ¶
GetOptionTime config Time depends on Module name
func GetOutputForModule ¶ added in v1.0.3
GetOutputForModule generates output value depends on module name
func IsValidConfigType ¶
IsValidConfigType checks if the provided type is valid for the module
func IsValidConfigTypeSlice ¶
IsValidConfigTypeSlice checks if all elements of userElements are in allowedElements, considering the counts of each element.
func OptionsFromConfig ¶
OptionsFromConfig reads options from config file
func SyncOptionsFromFlags ¶
func SyncOptionsFromFlags(fs afero.Fs, config *Config, flagMap map[string]string) (str.Options, error)
SyncOptionsFromFlags reads options from user flags
func ValidateConfig ¶
func ValidateConfig(module string, config OptionsConfig) bool
ValidateConfig validates if the provided configuration is allowed for the given module
Types ¶
type Config ¶
type Config struct {
Action string `toml:"action"`
ClientID string `toml:"client_id"`
ClientSecret string `toml:"client_secret"`
Comment string `toml:"comment"`
CommentID int `toml:"comment_id"`
CommentType string `toml:"comment_type"`
CommentsSort string `toml:"sort"`
ConfigPath string `toml:"config_path"`
CountSpecials string `toml:"count_specials"`
Days int `toml:"days"`
Delete bool `toml:"delete"`
Deny bool `toml:"deny"`
DisplayNumbers bool `toml:"display_numbers"`
AllowComments bool `toml:"allow_comments"`
Description string `toml:"description"`
EndAt string `toml:"end_at"`
Episode int `toml:"episode"`
EpisodeAbs int `toml:"episode_abs"`
EpisodeCode string `toml:"episode_code"`
EpisodesSort string `toml:"sort"`
EpisodesType string `toml:"type"`
ErrorCode int `toml:"errorCode"`
Field string `toml:"field"`
Format string `toml:"format"`
Hidden string `toml:"hidden"`
Hide bool `toml:"hide"`
ID string `toml:"id"`
ItemID int `toml:"item_id"`
IgnoreCollected string `toml:"ignore_collected"`
IgnoreWatchlisted string `toml:"ignore_watchlisted"`
IncludeReplies string `toml:"include_replies"`
InternalID string `toml:"trakt_id"`
Item string `toml:"item"`
Language string `toml:"language"`
List string `toml:"list"`
ListItemID int `toml:"list_item_id"`
Module string `toml:"module"`
MoviesCountry string `toml:"country"`
MoviesLanguage string `toml:"language"`
MoviesPeriod string `toml:"period"`
MoviesSort string `toml:"sort"`
MoviesType string `toml:"type"`
Msg string `toml:"msg"`
Notes string `toml:"notes"`
NotesID int `toml:"notes_id"`
Output string `toml:"output"`
PagesLimit int `toml:"pages_limit"`
PlaybackID int `toml:"playback_id"`
PerPage int `toml:"per_page"`
Privacy string `toml:"privacy"`
Progress float64 `toml:"progress"`
Query string `toml:"query"`
RedirectURI string `toml:"redirect_uri"`
Rating string `toml:"rating"`
Remove bool `toml:"remove"`
Reason string `toml:"reason"`
Reply string `toml:"reply"`
FollowerRequest int `toml:"follower_request"`
SearchField str.Slice `toml:"search_field"`
SearchIDType string `toml:"search_id_type"`
SearchType str.Slice `toml:"search_type"`
Season int `toml:"season"`
SeasonsSort string `toml:"sort"`
SeasonsType string `toml:"type"`
SettingsPath string `toml:"settings_path"`
ShowsCountry string `toml:"country"`
ShowsLanguage string `toml:"language"`
ShowsPeriod string `toml:"period"`
ShowsSort string `toml:"sort"`
ShowsType string `toml:"type"`
Sort string `toml:"sort"`
SortBy string `toml:"sort_by"`
SortHow string `toml:"sort_how"`
Specials string `toml:"specials"`
Spoiler bool `toml:"spoiler"`
StartAt string `toml:"start_at"`
Timezone string `toml:"timezone"`
TokenPath string `toml:"token_path"`
TraktID int `toml:"trakt_id"`
Translations string `toml:"translations"`
Type string `toml:"type"`
Undo bool `toml:"undo"`
UserName string `toml:"username"`
UsersType string `toml:"type"`
UsersSort string `toml:"type"`
UsersSection string `toml:"section"`
Verbose bool `toml:"verbose"`
WarningCode int `toml:"warningCode"`
}
Config struct for app.
type OptionsConfig ¶
type OptionsConfig struct {
SearchIDType []string
IncludeReplies []string
CommentType []string
SearchType []string
SearchField []string
Type []string
Section []string
Period []string
Sort []string
SortBy []string
SortHow []string
Format []string
Action []string
Privacy []string
Rating []int
Reason []string
}
OptionsConfig represents the configuration options for each module