Skip to content

Commit

Permalink
Add: Anime name and episode in mpv title
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraient committed Dec 18, 2024
1 parent 075c06a commit c71c910
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/curd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/localTracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion internal/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit c71c910

Please sign in to comment.