Commit 1d2cc6f5fa
Unsigned
Layout: unified · split
cmd/curd/main.go +19 −9
| @@ -528,17 +528,31 @@ func main() { | |||
| 528 | 528 | ||
| 529 | if anime.Ep.IsCompleted && !anime.Rewatching { | 529 | if anime.Ep.IsCompleted && !anime.Rewatching { |
| 530 | // Update progress for both regular episodes and skipped fillers | 530 | // Update progress for both regular episodes and skipped fillers |
| 531 | go func() { | 531 | if anime.TotalEpisodes > 0 && anime.Ep.Number-1 != anime.TotalEpisodes { |
| 532 | go func() { | ||
| 533 | // Update progress for regular episodes | ||
| 534 | err = internal.UpdateAnimeProgress(user.Token, anime.AnilistId, anime.Ep.Number-1) | ||
| 535 | if err != nil { | ||
| 536 | internal.Log("Error updating Anilist progress: " + err.Error()) | ||
| 537 | } | ||
| 538 | }() | ||
| 539 | } else { | ||
| 540 | // Update progress for last episode | ||
| 541 | |||
| 542 | // Exit MPV | ||
| 543 | internal.ExitMPV(anime.Ep.Player.SocketPath) | ||
| 544 | |||
| 532 | err = internal.UpdateAnimeProgress(user.Token, anime.AnilistId, anime.Ep.Number-1) | 545 | err = internal.UpdateAnimeProgress(user.Token, anime.AnilistId, anime.Ep.Number-1) |
| 533 | if err != nil { | 546 | if err != nil { |
| 534 | internal.Log("Error updating Anilist progress: "+err.Error()) | 547 | internal.Log("Error updating Anilist progress: " + err.Error()) |
| 535 | } | 548 | } |
| 536 | }() | 549 | } |
| 537 | 550 | ||
| 538 | anime.Ep.IsCompleted = false | 551 | anime.Ep.IsCompleted = false |
| 539 | // Only mark as complete and prompt for rating if we've reached the total episodes | 552 | // Only mark as complete and prompt for rating if we've reached the total episodes |
| 540 | // AND the anime is not currently airing (total episodes > 0) | 553 | // AND the anime is not currently airing (total episodes > 0) |
| 541 | if anime.Ep.Number-1 == anime.TotalEpisodes && userCurdConfig.ScoreOnCompletion && anime.TotalEpisodes > 0 { | 554 | if anime.Ep.Number-1 == anime.TotalEpisodes && userCurdConfig.ScoreOnCompletion && anime.TotalEpisodes > 0 { |
| 555 | |||
| 542 | // Get updated anime data to check if it's still airing | 556 | // Get updated anime data to check if it's still airing |
| 543 | updatedAnime, err := internal.GetAnimeDataByID(anime.AnilistId, user.Token) | 557 | updatedAnime, err := internal.GetAnimeDataByID(anime.AnilistId, user.Token) |
| 544 | if err != nil { | 558 | if err != nil { |
| @@ -572,11 +586,7 @@ func main() { | |||
| 572 | } | 586 | } |
| 573 | 587 | ||
| 574 | if selectedOption.Key != "yes" { | 588 | if selectedOption.Key != "yes" { |
| 575 | // Send command to close MPV | 589 | internal.ExitMPV(anime.Ep.Player.SocketPath) |
| 576 | _, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"quit"}) | ||
| 577 | if err != nil { | ||
| 578 | internal.Log("Error closing MPV: "+err.Error()) | ||
| 579 | } | ||
| 580 | internal.ExitCurd(nil) | 590 | internal.ExitCurd(nil) |
| 581 | } | 591 | } |
| 582 | // If yes or any other case, continue with the next episode | 592 | // If yes or any other case, continue with the next episode |
go.mod +4 −2
| @@ -1,13 +1,15 @@ | |||
| 1 | module github.com/wraient/curd | 1 | module github.com/wraient/curd |
| 2 | 2 | ||
| 3 | go 1.24.0 | 3 | go 1.23 |
| 4 | |||
| 5 | toolchain go1.24.0 | ||
| 4 | 6 | ||
| 5 | require ( | 7 | require ( |
| 6 | github.com/Microsoft/go-winio v0.6.2 | 8 | github.com/Microsoft/go-winio v0.6.2 |
| 7 | github.com/charmbracelet/bubbletea v1.3.3 | 9 | github.com/charmbracelet/bubbletea v1.3.3 |
| 8 | github.com/charmbracelet/lipgloss v1.0.0 | 10 | github.com/charmbracelet/lipgloss v1.0.0 |
| 9 | github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 | 11 | github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 |
| 10 | github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a | 12 | github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2 |
| 11 | ) | 13 | ) |
| 12 | 14 | ||
| 13 | require ( | 15 | require ( |
go.sum +2 −2
| @@ -18,6 +18,8 @@ github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/Oq | |||
| 18 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= | 18 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= |
| 19 | github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= | 19 | github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= |
| 20 | github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | 20 | github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= |
| 21 | github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2 h1:9qOViOQGFIP5ar+2NorfAIsfuADEKXtklySC0zNnYf4= | ||
| 22 | github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2/go.mod h1:nGaW7CGfNZnhtiFxMpc4OZdqIexGXjUlBnlmpZmjEKA= | ||
| 21 | github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= | 23 | github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= |
| 22 | github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= | 24 | github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= |
| 23 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= | 25 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
| @@ -39,8 +41,6 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= | |||
| 39 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= | 41 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
| 40 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk= | 42 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk= |
| 41 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= | 43 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= |
| 42 | github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a h1:J6QBl/BbJglPMI3BBhbGHjEEc6Ju+mvh/+ylv39tELw= | ||
| 43 | github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a/go.mod h1:VUn80i3gP5BKP8LjJh37rJy9o4P1CLj2z+w4CloUNhU= | ||
| 44 | golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= | 44 | golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= |
| 45 | golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | 45 | golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= |
| 46 | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 46 | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
internal/discord.go +11 −13
| @@ -2,8 +2,7 @@ package internal | |||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | 5 | "github.com/hugolgst/rich-go/client" | |
| 6 | "github.com/wraient/rich-go/client" | ||
| 7 | ) | 6 | ) |
| 8 | 7 | ||
| 9 | func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { | 8 | func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { |
| @@ -14,14 +13,14 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { | |||
| 14 | 13 | ||
| 15 | var state string | 14 | var state string |
| 16 | if IsPaused { | 15 | if IsPaused { |
| 17 | state = fmt.Sprintf("\nEpisode %d - %s (Paused)", | 16 | state = fmt.Sprintf("\nEpisode %d - %s (Paused)", |
| 18 | anime.Ep.Number, | 17 | anime.Ep.Number, |
| 19 | FormatTime(anime.Ep.Player.PlaybackTime), | 18 | FormatTime(anime.Ep.Player.PlaybackTime), |
| 20 | ) | 19 | ) |
| 21 | } else { | 20 | } else { |
| 22 | state = fmt.Sprintf("\nEpisode %d - %s / %s", | 21 | state = fmt.Sprintf("\nEpisode %d - %s / %s", |
| 23 | anime.Ep.Number, | 22 | anime.Ep.Number, |
| 24 | FormatTime(anime.Ep.Player.PlaybackTime), | 23 | FormatTime(anime.Ep.Player.PlaybackTime), |
| 25 | FormatTime(anime.Ep.Duration), | 24 | FormatTime(anime.Ep.Duration), |
| 26 | ) | 25 | ) |
| 27 | } | 26 | } |
| @@ -31,16 +30,15 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { | |||
| 31 | LargeImage: anime.CoverImage, | 30 | LargeImage: anime.CoverImage, |
| 32 | LargeText: GetAnimeName(anime), // Would display while hovering over the large image | 31 | LargeText: GetAnimeName(anime), // Would display while hovering over the large image |
| 33 | State: state, | 32 | State: state, |
| 34 | Type: 3, // Watching type (0 = Playing, 1 = Streaming, 2 = Listening, 3 = Watching, 4 = Custom, 5 = Competing) | ||
| 35 | //SmallImage: anime.SmallCoverImage, // Image for the bottom left corner | 33 | //SmallImage: anime.SmallCoverImage, // Image for the bottom left corner |
| 36 | //SmallText: fmt.Sprintf("Episode: %s", anime.Ep.Title.English), // Text when hovering over the small image | 34 | //SmallText: fmt.Sprintf("Episode: %s", anime.Ep.Title.English), // Text when hovering over the small image |
| 37 | Buttons: []*client.Button{ | 35 | Buttons: []*client.Button{ |
| 38 | { | 36 | &client.Button{ |
| 39 | Label: "View on AniList", // Button label | 37 | Label: "View on AniList", // Button label |
| 40 | Url: fmt.Sprintf("https://anilist.co/anime/%d", anime.AnilistId), // Button link | 38 | Url: fmt.Sprintf("https://anilist.co/anime/%d", anime.AnilistId), // Button link |
| 41 | }, | 39 | }, |
| 42 | { | 40 | &client.Button{ |
| 43 | Label: "View on MAL", // Button label | 41 | Label: "View on MAL", // Button label |
| 44 | Url: fmt.Sprintf("https://myanimelist.net/anime/%d", anime.MalId), // Button link | 42 | Url: fmt.Sprintf("https://myanimelist.net/anime/%d", anime.MalId), // Button link |
| 45 | }, | 43 | }, |
| 46 | }, | 44 | }, |
| @@ -64,4 +62,4 @@ func FormatTime(seconds int) string { | |||
| 64 | 62 | ||
| 65 | func ConvertSecondsToMinutes(seconds int) int { | 63 | func ConvertSecondsToMinutes(seconds int) int { |
| 66 | return seconds / 60 | 64 | return seconds / 60 |
| 67 | } | 65 | }\ No newline at end of file |
internal/player.go +9
| @@ -281,3 +281,12 @@ func IsMPVRunning(socketPath string) bool { | |||
| 281 | _, err = MPVSendCommand(socketPath, []interface{}{"get_property", "pid"}) | 281 | _, err = MPVSendCommand(socketPath, []interface{}{"get_property", "pid"}) |
| 282 | return err == nil | 282 | return err == nil |
| 283 | } | 283 | } |
| 284 | |||
| 285 | func ExitMPV(ipcSocketPath string) error { | ||
| 286 | // Send command to close MPV | ||
| 287 | _, err := MPVSendCommand(ipcSocketPath, []interface{}{"quit"}) | ||
| 288 | if err != nil { | ||
| 289 | Log("Error closing MPV: " + err.Error()) | ||
| 290 | } | ||
| 291 | return err | ||
| 292 | } | ||
vendor/github.com/wraient/rich-go/LICENSE → vendor/github.com/hugolgst/rich-go/LICENSE renamed
vendor/github.com/wraient/rich-go/client/client.go → vendor/github.com/hugolgst/rich-go/client/client.go renamed +1 −1
| @@ -6,7 +6,7 @@ import ( | |||
| 6 | "fmt" | 6 | "fmt" |
| 7 | "os" | 7 | "os" |
| 8 | 8 | ||
| 9 | "github.com/wraient/rich-go/ipc" | 9 | "github.com/hugolgst/rich-go/ipc" |
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | var logged bool | 12 | var logged bool |
vendor/github.com/wraient/rich-go/client/inputMapper.go → vendor/github.com/hugolgst/rich-go/client/inputMapper.go renamed −16
| @@ -4,28 +4,12 @@ import ( | |||
| 4 | "time" | 4 | "time" |
| 5 | ) | 5 | ) |
| 6 | 6 | ||
| 7 | // ActivityType represents the type of Discord rich presence activity | ||
| 8 | type ActivityType int | ||
| 9 | |||
| 10 | const ( | ||
| 11 | // ActivityTypePlaying represents "Playing ..." status | ||
| 12 | ActivityTypePlaying ActivityType = 0 | ||
| 13 | // ActivityTypeListening represents "Listening to ..." status | ||
| 14 | ActivityTypeListening ActivityType = 2 | ||
| 15 | // ActivityTypeWatching represents "Watching ..." status | ||
| 16 | ActivityTypeWatching ActivityType = 3 | ||
| 17 | // ActivityTypeCompeting represents "Competing in ..." status | ||
| 18 | ActivityTypeCompeting ActivityType = 5 | ||
| 19 | ) | ||
| 20 | |||
| 21 | // Activity holds the data for discord rich presence | 7 | // Activity holds the data for discord rich presence |
| 22 | type Activity struct { | 8 | type Activity struct { |
| 23 | // What the player is currently doing | 9 | // What the player is currently doing |
| 24 | Details string | 10 | Details string |
| 25 | // The user's current party status | 11 | // The user's current party status |
| 26 | State string | 12 | State string |
| 27 | // The activity type, defaults to Playing if not specified | ||
| 28 | Type ActivityType | ||
| 29 | // The id for a large asset of the activity, usually a snowflake | 13 | // The id for a large asset of the activity, usually a snowflake |
| 30 | LargeImage string | 14 | LargeImage string |
| 31 | // Text displayed when hovering over the large image of the activity | 15 | // Text displayed when hovering over the large image of the activity |
vendor/github.com/wraient/rich-go/client/types.go → vendor/github.com/hugolgst/rich-go/client/types.go renamed −1
| @@ -19,7 +19,6 @@ type Args struct { | |||
| 19 | type PayloadActivity struct { | 19 | type PayloadActivity struct { |
| 20 | Details string `json:"details,omitempty"` | 20 | Details string `json:"details,omitempty"` |
| 21 | State string `json:"state,omitempty"` | 21 | State string `json:"state,omitempty"` |
| 22 | Type ActivityType `json:"type,omitempty"` | ||
| 23 | Assets PayloadAssets `json:"assets,omitempty"` | 22 | Assets PayloadAssets `json:"assets,omitempty"` |
| 24 | Party *PayloadParty `json:"party,omitempty"` | 23 | Party *PayloadParty `json:"party,omitempty"` |
| 25 | Timestamps *PayloadTimestamps `json:"timestamps,omitempty"` | 24 | Timestamps *PayloadTimestamps `json:"timestamps,omitempty"` |
vendor/github.com/wraient/rich-go/ipc/ipc.go → vendor/github.com/hugolgst/rich-go/ipc/ipc.go renamed
vendor/github.com/wraient/rich-go/ipc/ipc_notwin.go → vendor/github.com/hugolgst/rich-go/ipc/ipc_notwin.go renamed −1
| @@ -1,4 +1,3 @@ | |||
| 1 | //go:build !windows | ||
| 2 | // +build !windows | 1 | // +build !windows |
| 3 | 2 | ||
| 4 | package ipc | 3 | package ipc |
vendor/github.com/wraient/rich-go/ipc/ipc_windows.go → vendor/github.com/hugolgst/rich-go/ipc/ipc_windows.go renamed +1 −3
| @@ -1,12 +1,10 @@ | |||
| 1 | //go:build windows | ||
| 2 | // +build windows | 1 | // +build windows |
| 3 | 2 | ||
| 4 | package ipc | 3 | package ipc |
| 5 | 4 | ||
| 6 | import ( | 5 | import ( |
| 7 | "time" | ||
| 8 | |||
| 9 | npipe "gopkg.in/natefinch/npipe.v2" | 6 | npipe "gopkg.in/natefinch/npipe.v2" |
| 7 | "time" | ||
| 10 | ) | 8 | ) |
| 11 | 9 | ||
| 12 | // OpenSocket opens the discord-ipc-0 named pipe | 10 | // OpenSocket opens the discord-ipc-0 named pipe |
vendor/modules.txt +4 −4
| @@ -34,6 +34,10 @@ github.com/go-toast/toast | |||
| 34 | # github.com/godbus/dbus/v5 v5.1.0 | 34 | # github.com/godbus/dbus/v5 v5.1.0 |
| 35 | ## explicit; go 1.12 | 35 | ## explicit; go 1.12 |
| 36 | github.com/godbus/dbus/v5 | 36 | github.com/godbus/dbus/v5 |
| 37 | # github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2 | ||
| 38 | ## explicit; go 1.17 | ||
| 39 | github.com/hugolgst/rich-go/client | ||
| 40 | github.com/hugolgst/rich-go/ipc | ||
| 37 | # github.com/lucasb-eyer/go-colorful v1.2.0 | 41 | # github.com/lucasb-eyer/go-colorful v1.2.0 |
| 38 | ## explicit; go 1.12 | 42 | ## explicit; go 1.12 |
| 39 | github.com/lucasb-eyer/go-colorful | 43 | github.com/lucasb-eyer/go-colorful |
| @@ -65,10 +69,6 @@ github.com/rivo/uniseg | |||
| 65 | # github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af | 69 | # github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af |
| 66 | ## explicit | 70 | ## explicit |
| 67 | github.com/tadvi/systray | 71 | github.com/tadvi/systray |
| 68 | # github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a | ||
| 69 | ## explicit; go 1.24.0 | ||
| 70 | github.com/wraient/rich-go/client | ||
| 71 | github.com/wraient/rich-go/ipc | ||
| 72 | # golang.org/x/sync v0.11.0 | 72 | # golang.org/x/sync v0.11.0 |
| 73 | ## explicit; go 1.18 | 73 | ## explicit; go 1.18 |
| 74 | golang.org/x/sync/errgroup | 74 | golang.org/x/sync/errgroup |