Commit 59f56b6c08

59f56b6c0890295e066a12fa51a0a123d3063b8f

parent: 8a0174b661

Unsigned

Wraient <wraient.911@gmail.com> · 2026-02-01 11:11 UTC

Test: android intent

Layout: unified · split

cmd/curd/main.go +36
@@ -295,6 +295,42 @@ func main() {
295 internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime)) 295 internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime))
296 internal.Log(anime.Ep.Player.SocketPath) 296 internal.Log(anime.Ep.Player.SocketPath)
297 297
298 // Handle Android Intent external player
299 if anime.Ep.Player.SocketPath == "android-intent" {
300 internal.CurdOut(fmt.Sprintf("\nOpened external player for Episode %d.", anime.Ep.Number))
301 internal.CurdOut("Press Enter when you have finished watching...")
302
303 // Wait for user input to confirm completion
304 var input string
305 fmt.Scanln(&input)
306
307 // Mark as completed
308 anime.Ep.IsCompleted = true
309
310 // Update progress for the finished episode
311 // Local update
312 internal.LocalUpdateAnime(databaseFile, anime.AnilistId, anime.AllanimeId, anime.Ep.Number, 0, 0, internal.GetAnimeName(anime))
313
314 // Check if we should continue to next episode
315 // On Android we always prompt because we don't know exactly when video ended
316 shouldContinue := internal.NextEpisodePromptCLI(&userCurdConfig)
317
318 if shouldContinue {
319 internal.StartNextEpisode(&anime, &userCurdConfig, databaseFile, user.Token)
320 continue
321 } else {
322 // Handle completion if this was the last episode
323 if anime.Ep.Number == anime.TotalEpisodes {
324 internal.HandleLastEpisodeCompletion(&userCurdConfig, &anime, user.Token)
325 }
326 // Update progress for the just finished episode (StartNextEpisode usually does this for previous ep, but here we exit)
327 if !anime.Rewatching {
328 internal.UpdateAnimeProgress(user.Token, anime.AnilistId, anime.Ep.Number)
329 }
330 internal.ExitCurd(nil)
331 }
332 }
333
298 wg.Add(1) 334 wg.Add(1)
299 // Get episode data 335 // Get episode data
300 go func() { 336 go func() {
internal/player.go +23 −1
@@ -3,6 +3,7 @@ package internal
3import ( 3import (
4 "crypto/rand" 4 "crypto/rand"
5 "encoding/json" 5 "encoding/json"
6 "errors"
6 "fmt" 7 "fmt"
7 "os" 8 "os"
8 "os/exec" 9 "os/exec"
@@ -11,7 +12,6 @@ import (
11 "strings" 12 "strings"
12 "sync" 13 "sync"
13 "time" 14 "time"
14 "errors"
15) 15)
16 16
17var logFile = "debug.log" 17var logFile = "debug.log"
@@ -106,6 +106,28 @@ func StartVideo(link string, args []string, title string, anime *Anime) (string,
106 mpvArgs = append(mpvArgs, args...) 106 mpvArgs = append(mpvArgs, args...)
107 } 107 }
108 108
109 // Check for Android environment
110 amPath, err := exec.LookPath("am")
111 isAndroid := runtime.GOOS == "android" || (err == nil && amPath != "")
112
113 if isAndroid {
114 // Only use MPV on Android via intent
115 cmdArgs := []string{
116 "start", "--user", "0",
117 "-a", "android.intent.action.VIEW",
118 "-d", link,
119 "-n", "is.xyz.mpv/.MPVActivity",
120 }
121
122 command = exec.Command("am", cmdArgs...)
123 err = command.Start()
124 if err != nil {
125 CurdOut("Error: Failed to start android intent")
126 return "", fmt.Errorf("failed to start android intent: %w", err)
127 }
128 return "android-intent", nil
129 }
130
109 if runtime.GOOS == "windows" { 131 if runtime.GOOS == "windows" {
110 // Get the path to mpv.exe for Windows 132 // Get the path to mpv.exe for Windows
111 mpvPath, err := getMPVPath() 133 mpvPath, err := getMPVPath()