Commit 77b283275f
Unregistered key
Layout: unified · split
cmd/curd/main.go +7
| @@ -447,6 +447,13 @@ func main() { | |||
| 447 | internal.Log("Error setting playback speed: "+err.Error()) | 447 | internal.Log("Error setting playback speed: "+err.Error()) |
| 448 | } | 448 | } |
| 449 | } | 449 | } |
| 450 | |||
| 451 | // Apply OP/ED Chapters | ||
| 452 | err = internal.SendSkipTimesToMPV(&anime) | ||
| 453 | if err != nil { | ||
| 454 | internal.Log("Error sending skip times to MPV: " + err.Error()) | ||
| 455 | } | ||
| 456 | fmt.Println("Skip times sent!") // TODO: REMOVE | ||
| 450 | } | 457 | } |
| 451 | 458 | ||
| 452 | // If resume is true, seek to the playback time | 459 | // If resume is true, seek to the playback time |
internal/aniskip.go +41
| @@ -101,3 +101,44 @@ func GetAndParseAniSkipData(animeMalId int, episode int, timePrecision int, anim | |||
| 101 | } | 101 | } |
| 102 | return ParseAniSkipResponse(responseText, anime, timePrecision) | 102 | return ParseAniSkipResponse(responseText, anime, timePrecision) |
| 103 | } | 103 | } |
| 104 | |||
| 105 | // Function to send OP and ED timings to MPV | ||
| 106 | func SendSkipTimesToMPV(anime *Anime) error { | ||
| 107 | chapterList := []map[string]interface{}{ | ||
| 108 | { | ||
| 109 | "title": "Pre-Opening", | ||
| 110 | "time": 0.0, | ||
| 111 | "end": float64(anime.Ep.SkipTimes.Op.Start), | ||
| 112 | }, | ||
| 113 | { | ||
| 114 | "title": "Opening", | ||
| 115 | "time": float64(anime.Ep.SkipTimes.Op.Start), | ||
| 116 | "end": float64(anime.Ep.SkipTimes.Op.End), | ||
| 117 | }, | ||
| 118 | { | ||
| 119 | "title": "Main", | ||
| 120 | "time": float64(anime.Ep.SkipTimes.Op.End), | ||
| 121 | "end": float64(anime.Ep.SkipTimes.Ed.Start), | ||
| 122 | }, | ||
| 123 | { | ||
| 124 | "title": "Ending", | ||
| 125 | "time": float64(anime.Ep.SkipTimes.Ed.Start), | ||
| 126 | "end": float64(anime.Ep.SkipTimes.Ed.End), | ||
| 127 | }, | ||
| 128 | { | ||
| 129 | "title": "Post-Credits", | ||
| 130 | "time": float64(anime.Ep.SkipTimes.Ed.End), | ||
| 131 | }, | ||
| 132 | } | ||
| 133 | |||
| 134 | _, err := MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{ | ||
| 135 | "set_property", | ||
| 136 | "chapter-list", | ||
| 137 | chapterList, | ||
| 138 | }) | ||
| 139 | if err != nil { | ||
| 140 | return fmt.Errorf("error sending command to MPV: %w", err) | ||
| 141 | } | ||
| 142 | |||
| 143 | return nil | ||
| 144 | } | ||