From c71c9104345767a5589f24f69a5f9e1ab391a0b1 Mon Sep 17 00:00:00 2001 From: Wraient Date: Wed, 18 Dec 2024 22:03:28 +0530 Subject: [PATCH] Add: Anime name and episode in mpv title --- internal/curd.go | 2 +- internal/localTracking.go | 2 +- internal/player.go | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/curd.go b/internal/curd.go index d21c8a5..e282f4c 100644 --- a/internal/curd.go +++ b/internal/curd.go @@ -943,7 +943,7 @@ func StartCurd(userCurdConfig *CurdConfig, anime *Anime, logFile string) string } else { CurdOut(fmt.Sprintf("%s - Episode %d", GetAnimeName(*anime), anime.Ep.Number)) } - mpvSocketPath, err := StartVideo(PrioritizeLink(anime.Ep.Links), []string{}) + mpvSocketPath, err := StartVideo(PrioritizeLink(anime.Ep.Links), []string{}, fmt.Sprintf("%s - Episode %d", GetAnimeName(*anime), anime.Ep.Number)) if err != nil { Log("Failed to start mpv", logFile) diff --git a/internal/localTracking.go b/internal/localTracking.go index f444e26..03c03e6 100644 --- a/internal/localTracking.go +++ b/internal/localTracking.go @@ -327,7 +327,7 @@ func WatchUntracked(userCurdConfig *CurdConfig, logFile string) { CurdOut(fmt.Sprintf("%s - Episode %d", GetAnimeName(anime), anime.Ep.Number)) // Start video playback - mpvSocketPath, err := StartVideo(PrioritizeLink(link), []string{}) + mpvSocketPath, err := StartVideo(PrioritizeLink(link), []string{}, fmt.Sprintf("%s - Episode %d", GetAnimeName(anime), anime.Ep.Number)) if err != nil { Log("Failed to start mpv", logFile) os.Exit(1) diff --git a/internal/player.go b/internal/player.go index 8821a6b..c89737b 100644 --- a/internal/player.go +++ b/internal/player.go @@ -24,7 +24,7 @@ func getMPVPath() (string, error) { return mpvPath, nil } -func StartVideo(link string, args []string) (string, error) { +func StartVideo(link string, args []string, title string) (string, error) { var command *exec.Cmd // Generate a random number for the socket path @@ -45,6 +45,10 @@ func StartVideo(link string, args []string) (string, error) { mpvSocketPath = fmt.Sprintf("/tmp/curd_mpvsocket_%s", randomNumber) } + // Add the title to MPV arguments + titleArg := fmt.Sprintf("--title=%s", title) + args = append(args, titleArg) + // Prepare arguments for mpv var mpvArgs []string mpvArgs = append(mpvArgs, "--no-terminal", "--really-quiet", fmt.Sprintf("--input-ipc-server=%s", mpvSocketPath), link)