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() {
72 } 72 }
73 } 73 }
74 74
75
75 // Start curd 76 // Start curd
76 mpvSocketPath := internal.StartCurd(&userCurdConfig, &anime, logFile) 77 if !anime.Ep.IsFiller {
77 78 fmt.Println("Not a filler episode, Starting: ", anime.Ep.Number)
78 internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile) 79 anime.Ep.Player.SocketPath = internal.StartCurd(&userCurdConfig, &anime, logFile)
79 internal.Log(mpvSocketPath, 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 }
80 86
87 wg.Add(1)
81 // Get episode data 88 // Get episode data
82 go func(){ 89 go func(){
90 defer wg.Done()
83 err = internal.GetEpisodeData(anime.MalId, anime.Ep.Number, &anime) 91 err = internal.GetEpisodeData(anime.MalId, anime.Ep.Number, &anime)
84 if err != nil { 92 if err != nil {
85 internal.Log("Error getting episode data: "+err.Error(), logFile) 93 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 }
86 } 115 }
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
94 }() 116 }()
95 117
96 wg.Add(1) 118 wg.Add(1)
@@ -132,8 +154,8 @@ func main() {
132 time.Sleep(1 * time.Second) 154 time.Sleep(1 * time.Second)
133 155
134 // Get current playback time 156 // Get current playback time
135 // internal.Log("Getting playback time"+mpvSocketPath, logFile) 157 internal.Log("Getting playback time"+anime.Ep.Player.SocketPath, logFile)
136 timePos, err := internal.MPVSendCommand(mpvSocketPath, []interface{}{"get_property", "time-pos"}) 158 timePos, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "time-pos"})
137 if err != nil { 159 if err != nil {
138 internal.Log("Error getting playback time: "+err.Error(), logFile) 160 internal.Log("Error getting playback time: "+err.Error(), logFile)
139 161
@@ -163,7 +185,7 @@ func main() {
163 185
164 // If resume is true, seek to the playback time 186 // If resume is true, seek to the playback time
165 if anime.Ep.Resume { 187 if anime.Ep.Resume {
166 internal.SeekMPV(mpvSocketPath, anime.Ep.Player.PlaybackTime) 188 internal.SeekMPV(anime.Ep.Player.SocketPath, anime.Ep.Player.PlaybackTime)
167 anime.Ep.Resume = false 189 anime.Ep.Resume = false
168 } 190 }
169 191
@@ -192,12 +214,12 @@ func main() {
192 // Check if MPV has started 214 // Check if MPV has started
193 if userCurdConfig.SkipOp { 215 if userCurdConfig.SkipOp {
194 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 { 216 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)
196 } 218 }
197 } 219 }
198 if userCurdConfig.SkipEd { 220 if userCurdConfig.SkipEd {
199 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 { 221 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)
201 } 223 }
202 } 224 }
203 } 225 }