Commit 1d2cc6f5fa

1d2cc6f5fa47ca0d6443acacf8b5f6b6e8febed6

parent: 8ac6471b06

Unsigned

Wraient <wraient.911@gmail.com> · 2025-02-22 18:28 UTC

Ver:
-Go version downgrade

- use hugolgst rich-go

Layout: unified · split

cmd/curd/main.go +19 −9
@@ -528,17 +528,31 @@ func main() {
528528
529529 if anime.Ep.IsCompleted && !anime.Rewatching {
530530 // 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
532545 err = internal.UpdateAnimeProgress(user.Token, anime.AnilistId, anime.Ep.Number-1)
533546 if err != nil {
534 internal.Log("Error updating Anilist progress: "+err.Error())
535 }
536 }()
547 internal.Log("Error updating Anilist progress: " + err.Error())
548 }
549 }
537550
538551 anime.Ep.IsCompleted = false
539552 // Only mark as complete and prompt for rating if we've reached the total episodes
540553 // AND the anime is not currently airing (total episodes > 0)
541554 if anime.Ep.Number-1 == anime.TotalEpisodes && userCurdConfig.ScoreOnCompletion && anime.TotalEpisodes > 0 {
555
542556 // Get updated anime data to check if it's still airing
543557 updatedAnime, err := internal.GetAnimeDataByID(anime.AnilistId, user.Token)
544558 if err != nil {
@@ -572,11 +586,7 @@ func main() {
572586 }
573587
574588 if selectedOption.Key != "yes" {
575 // Send command to close MPV
576 _, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"quit"})
577 if err != nil {
578 internal.Log("Error closing MPV: "+err.Error())
579 }
589 internal.ExitMPV(anime.Ep.Player.SocketPath)
580590 internal.ExitCurd(nil)
581591 }
582592 // If yes or any other case, continue with the next episode
go.mod +4 −2
@@ -1,13 +1,15 @@
11module github.com/wraient/curd
22
3go 1.24.0
3go 1.23
4
5toolchain go1.24.0
46
57require (
68 github.com/Microsoft/go-winio v0.6.2
79 github.com/charmbracelet/bubbletea v1.3.3
810 github.com/charmbracelet/lipgloss v1.0.0
911 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
1113)
1214
1315require (
go.sum +2 −2
@@ -18,6 +18,8 @@ github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/Oq
1818github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
1919github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
2020github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
21github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2 h1:9qOViOQGFIP5ar+2NorfAIsfuADEKXtklySC0zNnYf4=
22github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2/go.mod h1:nGaW7CGfNZnhtiFxMpc4OZdqIexGXjUlBnlmpZmjEKA=
2123github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
2224github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
2325github.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=
3941github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
4042github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk=
4143github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
42github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a h1:J6QBl/BbJglPMI3BBhbGHjEEc6Ju+mvh/+ylv39tELw=
43github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a/go.mod h1:VUn80i3gP5BKP8LjJh37rJy9o4P1CLj2z+w4CloUNhU=
4444golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
4545golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
4646golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
internal/discord.go +11 −13
@@ -2,8 +2,7 @@ package internal
22
33import (
44 "fmt"
5
6 "github.com/wraient/rich-go/client"
5 "github.com/hugolgst/rich-go/client"
76)
87
98func DiscordPresence(clientId string, anime Anime, IsPaused bool) error {
@@ -14,14 +13,14 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error {
1413
1514 var state string
1615 if IsPaused {
17 state = fmt.Sprintf("\nEpisode %d - %s (Paused)",
18 anime.Ep.Number,
16 state = fmt.Sprintf("\nEpisode %d - %s (Paused)",
17 anime.Ep.Number,
1918 FormatTime(anime.Ep.Player.PlaybackTime),
2019 )
2120 } else {
22 state = fmt.Sprintf("\nEpisode %d - %s / %s",
23 anime.Ep.Number,
24 FormatTime(anime.Ep.Player.PlaybackTime),
21 state = fmt.Sprintf("\nEpisode %d - %s / %s",
22 anime.Ep.Number,
23 FormatTime(anime.Ep.Player.PlaybackTime),
2524 FormatTime(anime.Ep.Duration),
2625 )
2726 }
@@ -31,16 +30,15 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error {
3130 LargeImage: anime.CoverImage,
3231 LargeText: GetAnimeName(anime), // Would display while hovering over the large image
3332 State: state,
34 Type: 3, // Watching type (0 = Playing, 1 = Streaming, 2 = Listening, 3 = Watching, 4 = Custom, 5 = Competing)
3533 //SmallImage: anime.SmallCoverImage, // Image for the bottom left corner
3634 //SmallText: fmt.Sprintf("Episode: %s", anime.Ep.Title.English), // Text when hovering over the small image
3735 Buttons: []*client.Button{
38 {
39 Label: "View on AniList", // Button label
36 &client.Button{
37 Label: "View on AniList", // Button label
4038 Url: fmt.Sprintf("https://anilist.co/anime/%d", anime.AnilistId), // Button link
4139 },
42 {
43 Label: "View on MAL", // Button label
40 &client.Button{
41 Label: "View on MAL", // Button label
4442 Url: fmt.Sprintf("https://myanimelist.net/anime/%d", anime.MalId), // Button link
4543 },
4644 },
@@ -64,4 +62,4 @@ func FormatTime(seconds int) string {
6462
6563func ConvertSecondsToMinutes(seconds int) int {
6664 return seconds / 60
67}
65}
\ No newline at end of file
internal/player.go +9
@@ -281,3 +281,12 @@ func IsMPVRunning(socketPath string) bool {
281281 _, err = MPVSendCommand(socketPath, []interface{}{"get_property", "pid"})
282282 return err == nil
283283}
284
285func 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 (
66 "fmt"
77 "os"
88
9 "github.com/wraient/rich-go/ipc"
9 "github.com/hugolgst/rich-go/ipc"
1010)
1111
1212var 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 (
44 "time"
55)
66
7// ActivityType represents the type of Discord rich presence activity
8type ActivityType int
9
10const (
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
217// Activity holds the data for discord rich presence
228type Activity struct {
239 // What the player is currently doing
2410 Details string
2511 // The user's current party status
2612 State string
27 // The activity type, defaults to Playing if not specified
28 Type ActivityType
2913 // The id for a large asset of the activity, usually a snowflake
3014 LargeImage string
3115 // 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 {
1919type PayloadActivity struct {
2020 Details string `json:"details,omitempty"`
2121 State string `json:"state,omitempty"`
22 Type ActivityType `json:"type,omitempty"`
2322 Assets PayloadAssets `json:"assets,omitempty"`
2423 Party *PayloadParty `json:"party,omitempty"`
2524 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
21// +build !windows
32
43package 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
21// +build windows
32
43package ipc
54
65import (
7 "time"
8
96 npipe "gopkg.in/natefinch/npipe.v2"
7 "time"
108)
119
1210// OpenSocket opens the discord-ipc-0 named pipe
vendor/modules.txt +4 −4
@@ -34,6 +34,10 @@ github.com/go-toast/toast
3434# github.com/godbus/dbus/v5 v5.1.0
3535## explicit; go 1.12
3636github.com/godbus/dbus/v5
37# github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2
38## explicit; go 1.17
39github.com/hugolgst/rich-go/client
40github.com/hugolgst/rich-go/ipc
3741# github.com/lucasb-eyer/go-colorful v1.2.0
3842## explicit; go 1.12
3943github.com/lucasb-eyer/go-colorful
@@ -65,10 +69,6 @@ github.com/rivo/uniseg
6569# github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af
6670## explicit
6771github.com/tadvi/systray
68# github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a
69## explicit; go 1.24.0
70github.com/wraient/rich-go/client
71github.com/wraient/rich-go/ipc
7272# golang.org/x/sync v0.11.0
7373## explicit; go 1.18
7474golang.org/x/sync/errgroup