Commit b7fb9a1a10

b7fb9a1a10ca38b7e66dc93d243a540c55ce9370

parent: 0ad93d0105

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-21 16:00 UTC

Add: Use aniskip

Layout: unified · split

cmd/curd/main.go +23 −1
@@ -21,6 +21,7 @@ func main() {
2121
2222 configFilePath := os.ExpandEnv("$HOME/Projects/curd/.config/curd/curd_config.txt")
2323 logFile := "debug.log"
24 internal.ClearLogFile(logFile)
2425
2526 // load curd userCurdConfig
2627 userCurdConfig, err := internal.LoadConfig(configFilePath)
@@ -71,9 +72,10 @@ func main() {
7172 internal.Log(anime, logFile)
7273 }()
7374
75 // Start curd
7476 mpvSocketPath := internal.StartCurd(&userCurdConfig, &anime, logFile)
7577
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)
7779 internal.Log(mpvSocketPath, logFile)
7880
7981 // Thread to update Discord presence
@@ -87,10 +89,19 @@ func main() {
8789 }
8890 }()
8991
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
90100 // Thread to update playback time in database
91101 go func() {
92102 for {
93103 time.Sleep(1 * time.Second)
104
94105 // Get current playback time
95106 timePos, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"})
96107 if err != nil {
@@ -134,6 +145,17 @@ func main() {
134145 currentTime, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"})
135146 if err != nil || currentTime == nil {
136147 }
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 }
137158 time.Sleep(1 * time.Second) // Wait before checking again
138159 }
160
139161}