Commit 4c0962cb42
Unsigned
Layout: unified · split
internal/config.go +59 −57
| @@ -38,35 +38,36 @@ type AnilistToken struct { | |||
| 38 | 38 | ||
| 39 | // CurdConfig struct with field names that match the config keys | 39 | // CurdConfig struct with field names that match the config keys |
| 40 | type CurdConfig struct { | 40 | type CurdConfig struct { |
| 41 | Player string `config:"Player"` | 41 | Player string `config:"Player"` |
| 42 | MpvArgs []string `config:"MpvArgs"` | 42 | MpvArgs []string `config:"MpvArgs"` |
| 43 | SubsLanguage string `config:"SubsLanguage"` | 43 | SubsLanguage string `config:"SubsLanguage"` |
| 44 | SubOrDub string `config:"SubOrDub"` | 44 | SubOrDub string `config:"SubOrDub"` |
| 45 | StoragePath string `config:"StoragePath"` | 45 | StoragePath string `config:"StoragePath"` |
| 46 | AnimeNameLanguage string `config:"AnimeNameLanguage"` | 46 | AnimeNameLanguage string `config:"AnimeNameLanguage"` |
| 47 | MenuOrder string `config:"MenuOrder"` | 47 | MenuOrder string `config:"MenuOrder"` |
| 48 | PercentageToMarkComplete int `config:"PercentageToMarkComplete"` | 48 | PercentageToMarkComplete int `config:"PercentageToMarkComplete"` |
| 49 | NextEpisodePrompt bool `config:"NextEpisodePrompt"` | 49 | NextEpisodePrompt bool `config:"NextEpisodePrompt"` |
| 50 | SkipOp bool `config:"SkipOp"` | 50 | SkipOp bool `config:"SkipOp"` |
| 51 | SkipEd bool `config:"SkipEd"` | 51 | SkipEd bool `config:"SkipEd"` |
| 52 | SkipFiller bool `config:"SkipFiller"` | 52 | SkipFiller bool `config:"SkipFiller"` |
| 53 | ImagePreview bool `config:"ImagePreview"` | 53 | ImagePreview bool `config:"ImagePreview"` |
| 54 | SkipRecap bool `config:"SkipRecap"` | 54 | SkipRecap bool `config:"SkipRecap"` |
| 55 | RofiSelection bool `config:"RofiSelection"` | 55 | RofiSelection bool `config:"RofiSelection"` |
| 56 | CurrentCategory bool `config:"CurrentCategory"` | 56 | CurrentCategory bool `config:"CurrentCategory"` |
| 57 | ScoreOnCompletion bool `config:"ScoreOnCompletion"` | 57 | ScoreOnCompletion bool `config:"ScoreOnCompletion"` |
| 58 | SaveMpvSpeed bool `config:"SaveMpvSpeed"` | 58 | SaveMpvSpeed bool `config:"SaveMpvSpeed"` |
| 59 | AddMissingOptions bool `config:"AddMissingOptions"` | 59 | AddMissingOptions bool `config:"AddMissingOptions"` |
| 60 | AlternateScreen bool `config:"AlternateScreen"` | 60 | AlternateScreen bool `config:"AlternateScreen"` |
| 61 | DiscordPresence bool `config:"DiscordPresence"` | 61 | DiscordPresence bool `config:"DiscordPresence"` |
| 62 | DiscordClientId string `config:"DiscordClientId"` | 62 | DiscordClientId string `config:"DiscordClientId"` |
| 63 | Provider string `config:"Provider"` | 63 | Provider string `config:"Provider"` |
| 64 | TrackingLocal bool `config:"TrackingLocal"` | 64 | TrackingLocal bool `config:"TrackingLocal"` |
| 65 | TrackingRemote string `config:"TrackingRemote"` | 65 | TrackingRemote string `config:"TrackingRemote"` |
| 66 | TrackingConfigured bool `config:"TrackingConfigured"` | 66 | TrackingConfigured bool `config:"TrackingConfigured"` |
| 67 | MyAnimeListClientID string `config:"MyAnimeListClientID"` | 67 | MyAnimeListClientID string `config:"MyAnimeListClientID"` |
| 68 | MyAnimeListClientSecret string `config:"MyAnimeListClientSecret"` | 68 | MyAnimeListClientSecret string `config:"MyAnimeListClientSecret"` |
| 69 | MyAnimeListImported bool `config:"MyAnimeListImported"` | 69 | MyAnimeListImported bool `config:"MyAnimeListImported"` |
| 70 | MyAnimeListImportDismissed bool `config:"MyAnimeListImportDismissed"` | ||
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | func GetStoragePath() string { | 73 | func GetStoragePath() string { |
| @@ -79,34 +80,35 @@ func GetStoragePath() string { | |||
| 79 | // Default configuration values as a map | 80 | // Default configuration values as a map |
| 80 | func defaultConfigMap() map[string]string { | 81 | func defaultConfigMap() map[string]string { |
| 81 | return map[string]string{ | 82 | return map[string]string{ |
| 82 | "Player": "mpv", | 83 | "Player": "mpv", |
| 83 | "MpvArgs": "[]", | 84 | "MpvArgs": "[]", |
| 84 | "StoragePath": "$HOME/.local/share/curd", | 85 | "StoragePath": "$HOME/.local/share/curd", |
| 85 | "AnimeNameLanguage": "english", | 86 | "AnimeNameLanguage": "english", |
| 86 | "SubsLanguage": "english", | 87 | "SubsLanguage": "english", |
| 87 | "MenuOrder": "CURRENT,ALL,UNTRACKED,UPDATE,CONTINUE_LAST,TRACKER,PROVIDER", | 88 | "MenuOrder": "CURRENT,ALL,UNTRACKED,UPDATE,CONTINUE_LAST,TRACKER,PROVIDER", |
| 88 | "SubOrDub": "sub", | 89 | "SubOrDub": "sub", |
| 89 | "PercentageToMarkComplete": "85", | 90 | "PercentageToMarkComplete": "85", |
| 90 | "NextEpisodePrompt": "false", | 91 | "NextEpisodePrompt": "false", |
| 91 | "SkipOp": "true", | 92 | "SkipOp": "true", |
| 92 | "SkipEd": "true", | 93 | "SkipEd": "true", |
| 93 | "SkipFiller": "true", | 94 | "SkipFiller": "true", |
| 94 | "SkipRecap": "true", | 95 | "SkipRecap": "true", |
| 95 | "RofiSelection": "false", | 96 | "RofiSelection": "false", |
| 96 | "ImagePreview": "false", | 97 | "ImagePreview": "false", |
| 97 | "ScoreOnCompletion": "true", | 98 | "ScoreOnCompletion": "true", |
| 98 | "SaveMpvSpeed": "true", | 99 | "SaveMpvSpeed": "true", |
| 99 | "AddMissingOptions": "true", | 100 | "AddMissingOptions": "true", |
| 100 | "AlternateScreen": "true", | 101 | "AlternateScreen": "true", |
| 101 | "DiscordPresence": "true", | 102 | "DiscordPresence": "true", |
| 102 | "DiscordClientId": "1287457464148820089", | 103 | "DiscordClientId": "1287457464148820089", |
| 103 | "Provider": "allanime", | 104 | "Provider": "allanime", |
| 104 | "TrackingLocal": "true", | 105 | "TrackingLocal": "true", |
| 105 | "TrackingRemote": "anilist", | 106 | "TrackingRemote": "anilist", |
| 106 | "TrackingConfigured": "false", | 107 | "TrackingConfigured": "false", |
| 107 | "MyAnimeListClientID": "f76d4c827152327b60654285d221222c", | 108 | "MyAnimeListClientID": "f76d4c827152327b60654285d221222c", |
| 108 | "MyAnimeListClientSecret": "", | 109 | "MyAnimeListClientSecret": "", |
| 109 | "MyAnimeListImported": "false", | 110 | "MyAnimeListImported": "false", |
| 111 | "MyAnimeListImportDismissed": "false", | ||
| 110 | } | 112 | } |
| 111 | } | 113 | } |
| 112 | 114 | ||
internal/tracking.go +7 −4
| @@ -142,6 +142,7 @@ func persistTrackingConfig(config *CurdConfig) error { | |||
| 142 | configMap["MyAnimeListClientID"] = config.MyAnimeListClientID | 142 | configMap["MyAnimeListClientID"] = config.MyAnimeListClientID |
| 143 | configMap["MyAnimeListClientSecret"] = config.MyAnimeListClientSecret | 143 | configMap["MyAnimeListClientSecret"] = config.MyAnimeListClientSecret |
| 144 | configMap["MyAnimeListImported"] = strconv.FormatBool(config.MyAnimeListImported) | 144 | configMap["MyAnimeListImported"] = strconv.FormatBool(config.MyAnimeListImported) |
| 145 | configMap["MyAnimeListImportDismissed"] = strconv.FormatBool(config.MyAnimeListImportDismissed) | ||
| 145 | 146 | ||
| 146 | return SaveConfigToFile(GlobalConfigPath, configMap) | 147 | return SaveConfigToFile(GlobalConfigPath, configMap) |
| 147 | } | 148 | } |
| @@ -1128,14 +1129,13 @@ func AddAnimeToList(animeID int, status string, token string) error { | |||
| 1128 | } | 1129 | } |
| 1129 | 1130 | ||
| 1130 | func maybeImportAniListToMyAnimeList(config *CurdConfig, user *User) error { | 1131 | func maybeImportAniListToMyAnimeList(config *CurdConfig, user *User) error { |
| 1131 | if config == nil || user == nil || !UsesMyAnimeListTracking(config) || config.MyAnimeListImported || hasAnyEntries(user.AnimeList) { | 1132 | if config == nil || user == nil || !UsesMyAnimeListTracking(config) || config.MyAnimeListImported || config.MyAnimeListImportDismissed || hasAnyEntries(user.AnimeList) { |
| 1132 | return nil | 1133 | return nil |
| 1133 | } | 1134 | } |
| 1134 | 1135 | ||
| 1135 | legacyTokenPath := filepath.Join(os.ExpandEnv(config.StoragePath), "anilist_token.json") | 1136 | legacyTokenPath := filepath.Join(os.ExpandEnv(config.StoragePath), "anilist_token.json") |
| 1136 | if _, err := os.Stat(legacyTokenPath); err != nil { | 1137 | if _, err := os.Stat(legacyTokenPath); err != nil { |
| 1137 | config.MyAnimeListImported = true | 1138 | return nil |
| 1138 | return persistTrackingConfig(config) | ||
| 1139 | } | 1139 | } |
| 1140 | 1140 | ||
| 1141 | options := []SelectionOption{ | 1141 | options := []SelectionOption{ |
| @@ -1156,9 +1156,12 @@ func maybeImportAniListToMyAnimeList(config *CurdConfig, user *User) error { | |||
| 1156 | if err := RefreshMyAnimeListUserAnimeList(config, user); err != nil { | 1156 | if err := RefreshMyAnimeListUserAnimeList(config, user); err != nil { |
| 1157 | return err | 1157 | return err |
| 1158 | } | 1158 | } |
| 1159 | config.MyAnimeListImported = true | ||
| 1160 | config.MyAnimeListImportDismissed = false | ||
| 1161 | return persistTrackingConfig(config) | ||
| 1159 | } | 1162 | } |
| 1160 | 1163 | ||
| 1161 | config.MyAnimeListImported = true | 1164 | config.MyAnimeListImportDismissed = true |
| 1162 | return persistTrackingConfig(config) | 1165 | return persistTrackingConfig(config) |
| 1163 | } | 1166 | } |
| 1164 | 1167 | ||