Commit e0ad0d4644

e0ad0d4644ad9e55fcbdafec658e0e81e737def6

parent: 0b08ceabd3

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-22 09:07 UTC

Imp: Does not work maybe but need to stash

Layout: unified · split

cmd/curd/main.go +38 −16
@@ -72,25 +72,47 @@ func main() {
7272 }
7373 }
7474
75
7576 // Start curd
76 mpvSocketPath := internal.StartCurd(&userCurdConfig, &anime, logFile)
77
78 internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile)
79 internal.Log(mpvSocketPath, logFile)
77 if !anime.Ep.IsFiller {
78 fmt.Println("Not a filler episode, Starting: ", anime.Ep.Number)
79 anime.Ep.Player.SocketPath = internal.StartCurd(&userCurdConfig, &anime, logFile)
80
81 internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile)
82 internal.Log(anime.Ep.Player.SocketPath, logFile)
83 } else {
84 fmt.Println("Filler episode, skipping: ", anime.Ep.Number)
85 }
8086
87 wg.Add(1)
8188 // Get episode data
8289 go func(){
90 defer wg.Done()
8391 err = internal.GetEpisodeData(anime.MalId, anime.Ep.Number, &anime)
8492 if err != nil {
8593 internal.Log("Error getting episode data: "+err.Error(), logFile)
94 } else{
95 internal.Log(anime, logFile)
96
97 // if filler episode
98 if anime.Ep.IsFiller {
99 fmt.Println("Filler Episode, starting next episode: ", anime.Ep.Number+1)
100 internal.Log("Filler episode detected", logFile)
101 anime.Ep.Number++
102 anime.Ep.Started = false
103 internal.Log("Skipping filler episode, starting next.", logFile)
104 internal.LocalUpdateAnime(databaseFile, anime.AnilistId, anime.AllanimeId, anime.Ep.Number, anime.Ep.Player.PlaybackTime, anime.Title.English)
105 // Send command to close MPV
106 _, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"quit"})
107 if err != nil {
108 internal.Log("Error closing MPV: "+err.Error(), logFile)
109 }
110 // Exit the skip loop
111 close(skipLoopDone)
112 } else {
113 // fmt.Println("Not a filler episode, Starting: ", anime.Ep.Number)
114 }
86115 }
87 internal.Log(anime, logFile)
88
89 if anime.Ep.IsFiller {
90 internal.Log("Filler episode", logFile)
91 internal.SeekMPV(mpvSocketPath, anime.Ep.Duration)
92 }
93
94116 }()
95117
96118 wg.Add(1)
@@ -132,8 +154,8 @@ func main() {
132154 time.Sleep(1 * time.Second)
133155
134156 // Get current playback time
135 // internal.Log("Getting playback time"+mpvSocketPath, logFile)
136 timePos, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"})
157 internal.Log("Getting playback time"+anime.Ep.Player.SocketPath, logFile)
158 timePos, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "time-pos"})
137159 if err != nil {
138160 internal.Log("Error getting playback time: "+err.Error(), logFile)
139161
@@ -163,7 +185,7 @@ func main() {
163185
164186 // If resume is true, seek to the playback time
165187 if anime.Ep.Resume {
166 internal.SeekMPV(mpvSocketPath, anime.Ep.Player.PlaybackTime)
188 internal.SeekMPV(anime.Ep.Player.SocketPath, anime.Ep.Player.PlaybackTime)
167189 anime.Ep.Resume = false
168190 }
169191
@@ -192,12 +214,12 @@ func main() {
192214 // Check if MPV has started
193215 if userCurdConfig.SkipOp {
194216 if anime.Ep.Player.PlaybackTime > anime.Ep.SkipTimes.Op.Start && anime.Ep.Player.PlaybackTime < anime.Ep.SkipTimes.Op.Start+2 && anime.Ep.SkipTimes.Op.Start != anime.Ep.SkipTimes.Op.End {
195 internal.SeekMPV(mpvSocketPath, anime.Ep.SkipTimes.Op.End)
217 internal.SeekMPV(anime.Ep.Player.SocketPath, anime.Ep.SkipTimes.Op.End)
196218 }
197219 }
198220 if userCurdConfig.SkipEd {
199221 if anime.Ep.Player.PlaybackTime > anime.Ep.SkipTimes.Ed.Start && anime.Ep.Player.PlaybackTime < anime.Ep.SkipTimes.Ed.Start+2 && anime.Ep.SkipTimes.Ed.Start != anime.Ep.SkipTimes.Ed.End {
200 internal.SeekMPV(mpvSocketPath, anime.Ep.SkipTimes.Ed.End)
222 internal.SeekMPV(anime.Ep.Player.SocketPath, anime.Ep.SkipTimes.Ed.End)
201223 }
202224 }
203225 }