Commit 22c5b81107
Unsigned
Layout: unified · split
cmd/curd/main.go +11 −7
| @@ -154,31 +154,29 @@ func main() { | ||
| 154 | 154 | time.Sleep(1 * time.Second) |
| 155 | 155 | |
| 156 | 156 | // Get current playback time |
| 157 | internal.Log("Getting playback time"+anime.Ep.Player.SocketPath, logFile) | |
| 157 | internal.Log("Getting playback time "+anime.Ep.Player.SocketPath, logFile) | |
| 158 | 158 | timePos, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "time-pos"}) |
| 159 | 159 | if err != nil { |
| 160 | 160 | internal.Log("Error getting playback time: "+err.Error(), logFile) |
| 161 | 161 | |
| 162 | 162 | // User closed the video |
| 163 | 163 | if anime.Ep.Started { |
| 164 | ||
| 165 | 164 | if int(*internal.PercentageWatched(anime.Ep.Player.PlaybackTime, anime.Ep.Duration)) >= userCurdConfig.PercentageToMarkComplete { |
| 166 | 165 | anime.Ep.Number++ |
| 167 | 166 | anime.Ep.Started = false |
| 168 | 167 | internal.Log("Completed episode, starting next.", logFile) |
| 169 | 168 | // Exit the skip loop |
| 170 | 169 | close(skipLoopDone) |
| 171 | // continue | |
| 172 | } else{ | |
| 170 | } else { | |
| 173 | 171 | fmt.Println("Have a great day!") |
| 174 | 172 | os.Exit(0) |
| 175 | 173 | } |
| 176 | ||
| 177 | 174 | } |
| 175 | continue | |
| 178 | 176 | } |
| 179 | 177 | |
| 180 | 178 | // Convert timePos to integer |
| 181 | if timePos != nil && err == nil { | |
| 179 | if timePos != nil { | |
| 182 | 180 | if !anime.Ep.Started { |
| 183 | 181 | anime.Ep.Started = true |
| 184 | 182 | } |
| @@ -197,7 +195,13 @@ func main() { | ||
| 197 | 195 | |
| 198 | 196 | anime.Ep.Player.PlaybackTime = int(animePosition + 0.5) // Round to nearest integer |
| 199 | 197 | // Update Local Database |
| 200 | internal.LocalUpdateAnime(databaseFile, anime.AnilistId, anime.AllanimeId, anime.Ep.Number, anime.Ep.Player.PlaybackTime, anime.Title.English) | |
| 198 | err = internal.LocalUpdateAnime(databaseFile, anime.AnilistId, anime.AllanimeId, anime.Ep.Number, anime.Ep.Player.PlaybackTime, anime.Title.English) | |
| 199 | if err != nil { | |
| 200 | internal.Log("Error updating local database: "+err.Error(), logFile) | |
| 201 | } else { | |
| 202 | internal.Log(fmt.Sprintf("Updated database: AnilistId=%d, AllanimeId=%s, EpNumber=%d, PlaybackTime=%d", | |
| 203 | anime.AnilistId, anime.AllanimeId, anime.Ep.Number, anime.Ep.Player.PlaybackTime), logFile) | |
| 204 | } | |
| 201 | 205 | } |
| 202 | 206 | } |
| 203 | 207 | } |