Commit b7fb9a1a10
Unsigned
Layout: unified · split
cmd/curd/main.go +23 −1
| @@ -21,6 +21,7 @@ func main() { | |||
| 21 | 21 | ||
| 22 | configFilePath := os.ExpandEnv("$HOME/Projects/curd/.config/curd/curd_config.txt") | 22 | configFilePath := os.ExpandEnv("$HOME/Projects/curd/.config/curd/curd_config.txt") |
| 23 | logFile := "debug.log" | 23 | logFile := "debug.log" |
| 24 | internal.ClearLogFile(logFile) | ||
| 24 | 25 | ||
| 25 | // load curd userCurdConfig | 26 | // load curd userCurdConfig |
| 26 | userCurdConfig, err := internal.LoadConfig(configFilePath) | 27 | userCurdConfig, err := internal.LoadConfig(configFilePath) |
| @@ -71,9 +72,10 @@ func main() { | |||
| 71 | internal.Log(anime, logFile) | 72 | internal.Log(anime, logFile) |
| 72 | }() | 73 | }() |
| 73 | 74 | ||
| 75 | // Start curd | ||
| 74 | mpvSocketPath := internal.StartCurd(&userCurdConfig, &anime, logFile) | 76 | mpvSocketPath := internal.StartCurd(&userCurdConfig, &anime, logFile) |
| 75 | 77 | ||
| 76 | internal.Log(fmt.Sprint("starting from: ", anime.Ep.Player.PlaybackTime), logFile) | 78 | internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile) |
| 77 | internal.Log(mpvSocketPath, logFile) | 79 | internal.Log(mpvSocketPath, logFile) |
| 78 | 80 | ||
| 79 | // Thread to update Discord presence | 81 | // Thread to update Discord presence |
| @@ -87,10 +89,19 @@ func main() { | |||
| 87 | } | 89 | } |
| 88 | }() | 90 | }() |
| 89 | 91 | ||
| 92 | go func() { | ||
| 93 | err = internal.GetAndParseAniSkipData(anime.MalId, anime.Ep.Number, 1, &anime) | ||
| 94 | if err != nil { | ||
| 95 | internal.Log("Error getting and parsing AniSkip data: "+err.Error(), logFile) | ||
| 96 | } | ||
| 97 | internal.Log(anime.Ep.SkipTimes, logFile) | ||
| 98 | }() | ||
| 99 | |||
| 90 | // Thread to update playback time in database | 100 | // Thread to update playback time in database |
| 91 | go func() { | 101 | go func() { |
| 92 | for { | 102 | for { |
| 93 | time.Sleep(1 * time.Second) | 103 | time.Sleep(1 * time.Second) |
| 104 | |||
| 94 | // Get current playback time | 105 | // Get current playback time |
| 95 | timePos, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"}) | 106 | timePos, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"}) |
| 96 | if err != nil { | 107 | if err != nil { |
| @@ -134,6 +145,17 @@ func main() { | |||
| 134 | currentTime, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"}) | 145 | currentTime, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"}) |
| 135 | if err != nil || currentTime == nil { | 146 | if err != nil || currentTime == nil { |
| 136 | } | 147 | } |
| 148 | if userCurdConfig.SkipOp { | ||
| 149 | if anime.Ep.Player.PlaybackTime > anime.Ep.SkipTimes.Op.Start && anime.Ep.Player.PlaybackTime < anime.Ep.SkipTimes.Op.Start+2 { | ||
| 150 | internal.SeekMPV(mpvSocketPath, anime.Ep.SkipTimes.Op.End) | ||
| 151 | } | ||
| 152 | } | ||
| 153 | if userCurdConfig.SkipEd { | ||
| 154 | if anime.Ep.Player.PlaybackTime > anime.Ep.SkipTimes.Ed.Start && anime.Ep.Player.PlaybackTime < anime.Ep.SkipTimes.Ed.Start+2 { | ||
| 155 | internal.SeekMPV(mpvSocketPath, anime.Ep.SkipTimes.Ed.End) | ||
| 156 | } | ||
| 157 | } | ||
| 137 | time.Sleep(1 * time.Second) // Wait before checking again | 158 | time.Sleep(1 * time.Second) // Wait before checking again |
| 138 | } | 159 | } |
| 160 | |||
| 139 | } | 161 | } |