diff --git a/cmd/curd/main.go b/cmd/curd/main.go index 1bd7f92..ea442b4 100644 --- a/cmd/curd/main.go +++ b/cmd/curd/main.go @@ -197,7 +197,7 @@ func main() { if err != nil { internal.Log("Error getting anime ID and image: "+err.Error(), logFile) } - err = internal.DiscordPresence(discordClientId, anime) + err = internal.DiscordPresence(discordClientId, anime, false) if err != nil { internal.Log("Error setting Discord presence: "+err.Error(), logFile) } @@ -264,7 +264,16 @@ func main() { case <-skipLoopDone: return default: - err = internal.DiscordPresence(discordClientId, anime) + isPaused, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "pause"}) + if err != nil { + internal.Log("Error getting pause status: "+err.Error(), logFile) + } + if isPaused == nil { + isPaused = true + } else { + isPaused = isPaused.(bool) + } + err = internal.DiscordPresence(discordClientId, anime, isPaused.(bool)) if err != nil { // internal.Log("Error setting Discord presence: "+err.Error(), logFile) } diff --git a/internal/discord.go b/internal/discord.go index 6c00b28..9fd61bf 100644 --- a/internal/discord.go +++ b/internal/discord.go @@ -5,22 +5,32 @@ import ( "github.com/hugolgst/rich-go/client" ) -func DiscordPresence(clientId string, anime Anime) error { +func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { err := client.Login(clientId) if err != nil { return err } - - err = client.SetActivity(client.Activity{ - Details: fmt.Sprintf("%s", GetAnimeName(anime)), // Large text - LargeImage: anime.CoverImage, - LargeText: GetAnimeName(anime), // Would display while hovering over the large image - State: fmt.Sprintf("\nEpisode %d - %d:%02d / %d:%02d", + var state string + if IsPaused { + state = fmt.Sprintf("\nEpisode %d - %d:%02d (Paused)", + anime.Ep.Number, + ConvertSecondsToMinutes(anime.Ep.Player.PlaybackTime), + anime.Ep.Player.PlaybackTime % 60, + ) + } else { + state = fmt.Sprintf("\nEpisode %d - %d:%02d / %d:%02d", anime.Ep.Number, ConvertSecondsToMinutes(anime.Ep.Player.PlaybackTime), anime.Ep.Player.PlaybackTime % 60, ConvertSecondsToMinutes(anime.Ep.Duration), - anime.Ep.Duration % 60), + anime.Ep.Duration % 60, + ) + } + err = client.SetActivity(client.Activity{ + Details: fmt.Sprintf("%s", GetAnimeName(anime)), // Large text + LargeImage: anime.CoverImage, + LargeText: GetAnimeName(anime), // Would display while hovering over the large image + State: state, // SmallImage: anime.CoverImage, // Image would appear in the bottom left corner // SmallText: fmt.Sprintf("%s", anime.Ep.Title.English), // Would display while hovering over the small image Buttons: []*client.Button{