Commit e4dbb2953b

e4dbb2953bff35e2d0cb53007c48a3cb0cc542ac

parent: 4d9874c1c4

Unsigned

Vedant Deshmukh <73630434+Vedant9500@users.noreply.github.com> · 2025-05-30 15:58 UTC

performed gofmt -s

Layout: unified · split

internal/anime_list.go +13 −13
@@ -5,16 +5,16 @@ import (
55 "fmt"
66 "io"
77 "net/http"
8 "net/url"
89 "os"
910 "path/filepath"
10 "net/url"
1111 // "strings"
1212)
1313
1414type anime struct {
15 ID string `json:"_id"`
16 Name string `json:"name"`
17 EnglishName string `json:"englishName"`
15 ID string `json:"_id"`
16 Name string `json:"name"`
17 EnglishName string `json:"englishName"`
1818 AvailableEpisodes interface{} `json:"availableEpisodes"`
1919}
2020
@@ -49,10 +49,10 @@ func SearchAnime(query, mode string) (map[string]string, error) {
4949 logFile = filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "debug.log")
5050 }
5151 const (
52 agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
53 allanimeRef = "https://allanime.to"
54 allanimeBase = "allanime.day"
55 allanimeAPI = "https://api." + allanimeBase + "/api"
52 agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
53 allanimeRef = "https://allanime.to"
54 allanimeBase = "allanime.day"
55 allanimeAPI = "https://api." + allanimeBase + "/api"
5656 )
5757
5858 // Prepare the anime list
@@ -73,12 +73,12 @@ func SearchAnime(query, mode string) (map[string]string, error) {
7373 // Prepare the GraphQL variables
7474 variables := map[string]interface{}{
7575 "search": map[string]interface{}{
76 "allowAdult": false,
77 "allowUnknown": false,
78 "query": query,
76 "allowAdult": false,
77 "allowUnknown": false,
78 "query": query,
7979 },
80 "limit": 40,
81 "page": 1,
80 "limit": 40,
81 "page": 1,
8282 "translationType": mode,
8383 "countryOrigin": "ALL",
8484 }
internal/discord.go +10 −10
@@ -17,14 +17,14 @@ func DiscordPresence(anime Anime, IsPaused bool) error {
1717
1818 var state string
1919 if IsPaused {
20 state = fmt.Sprintf("\nEpisode %d - %s (Paused)",
21 anime.Ep.Number,
20 state = fmt.Sprintf("\nEpisode %d - %s (Paused)",
21 anime.Ep.Number,
2222 FormatTime(anime.Ep.Player.PlaybackTime),
2323 )
2424 } else {
25 state = fmt.Sprintf("\nEpisode %d - %s / %s",
26 anime.Ep.Number,
27 FormatTime(anime.Ep.Player.PlaybackTime),
25 state = fmt.Sprintf("\nEpisode %d - %s / %s",
26 anime.Ep.Number,
27 FormatTime(anime.Ep.Player.PlaybackTime),
2828 FormatTime(anime.Ep.Duration),
2929 )
3030 }
@@ -37,12 +37,12 @@ func DiscordPresence(anime Anime, IsPaused bool) error {
3737 //SmallImage: anime.SmallCoverImage, // Image for the bottom left corner
3838 //SmallText: fmt.Sprintf("Episode: %s", anime.Ep.Title.English), // Text when hovering over the small image
3939 Buttons: []*client.Button{
40 &client.Button{
41 Label: "View on AniList", // Button label
40 {
41 Label: "View on AniList", // Button label
4242 Url: fmt.Sprintf("https://anilist.co/anime/%d", anime.AnilistId), // Button link
4343 },
44 &client.Button{
45 Label: "View on MAL", // Button label
44 {
45 Label: "View on MAL", // Button label
4646 Url: fmt.Sprintf("https://myanimelist.net/anime/%d", anime.MalId), // Button link
4747 },
4848 },
@@ -66,4 +66,4 @@ func FormatTime(seconds int) string {
6666
6767func ConvertSecondsToMinutes(seconds int) int {
6868 return seconds / 60
69}
\ No newline at end of file
69}
internal/episode_list.go +6 −6
@@ -12,7 +12,7 @@ import (
1212type episodesResponse struct {
1313 Data struct {
1414 Show struct {
15 ID string `json:"_id"`
15 ID string `json:"_id"`
1616 AvailableEpisodesDetail map[string]interface{} `json:"availableEpisodesDetail"`
1717 } `json:"show"`
1818 } `json:"data"`
@@ -33,14 +33,14 @@ type episodesResponse struct {
3333// episodesList performs the API call and fetches the episodes list
3434func EpisodesList(showID, mode string) ([]string, error) {
3535 const (
36 agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
37 allanimeRef = "https://allanime.to"
38 allanimeBase = "allanime.day"
39 allanimeAPI = "https://api." + allanimeBase + "/api"
36 agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
37 allanimeRef = "https://allanime.to"
38 allanimeBase = "allanime.day"
39 allanimeAPI = "https://api." + allanimeBase + "/api"
4040 )
4141
4242 episodesListGql := `query ($showId: String!) { show( _id: $showId ) { _id availableEpisodesDetail }}`
43
43
4444 // Build the request URL
4545 url := fmt.Sprintf("%s?variables={\"showId\":\"%s\"}&query=%s", allanimeAPI, showID, episodesListGql)
4646 episodes := []string{}
internal/episode_url.go −1
@@ -158,7 +158,6 @@ func GetEpisodeURL(config CurdConfig, id string, epNo int) ([]string, error) {
158158 return nil, err
159159 }
160160
161
162161 // Pre-count valid URLs and create slice to preserve order
163162 validURLs := make([]string, 0)
164163 highestPriority := -1
internal/jikan.go +2 −2
@@ -3,8 +3,8 @@ package internal
33import (
44 "encoding/json"
55 "fmt"
6 "net/http"
76 "io"
7 "net/http"
88)
99
1010// GetEpisodeData fetches episode data for a given anime ID and episode number
@@ -103,4 +103,4 @@ func makeGetRequest(url string, headers map[string]string) (map[string]interface
103103 }
104104
105105 return responseData, nil
106}
\ No newline at end of file
106}
internal/links.go −1
@@ -46,4 +46,3 @@ func PrioritizeLink(links []string) string {
4646
4747 return bestLink
4848}
49
internal/localTracking.go +4 −4
@@ -258,7 +258,7 @@ func WatchUntracked(userCurdConfig *CurdConfig) {
258258 if userCurdConfig.RofiSelection {
259259 userInput, err := GetUserInputFromRofi("Enter the anime name")
260260 if err != nil {
261 Log("Error getting user input: "+err.Error())
261 Log("Error getting user input: " + err.Error())
262262 ExitCurd(fmt.Errorf("Error getting user input: " + err.Error()))
263263 }
264264 query = userInput
@@ -297,7 +297,7 @@ func WatchUntracked(userCurdConfig *CurdConfig) {
297297 if userCurdConfig.RofiSelection {
298298 userInput, err := GetUserInputFromRofi("Enter the episode number")
299299 if err != nil {
300 Log("Error getting episode number: "+err.Error())
300 Log("Error getting episode number: " + err.Error())
301301 ExitCurd(fmt.Errorf("Error getting episode number: " + err.Error()))
302302 }
303303 episodeNumber, err = strconv.Atoi(userInput)
@@ -346,7 +346,7 @@ func WatchUntracked(userCurdConfig *CurdConfig) {
346346 // Get video duration
347347 durationPos, err := MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "duration"})
348348 if err != nil {
349 Log("Error getting video duration: "+err.Error())
349 Log("Error getting video duration: " + err.Error())
350350 } else if durationPos != nil {
351351 if duration, ok := durationPos.(float64); ok {
352352 anime.Ep.Duration = int(duration + 0.5) // Round to nearest integer
@@ -366,7 +366,7 @@ func WatchUntracked(userCurdConfig *CurdConfig) {
366366 for {
367367 timePos, err := MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "time-pos"})
368368 if err != nil {
369 Log("Error getting playback time: "+err.Error())
369 Log("Error getting playback time: " + err.Error())
370370
371371 // Check if the error is due to invalid JSON
372372 // User closed the video
internal/rofi.go +6 −6
@@ -3,8 +3,8 @@ package internal
33import (
44 "bytes"
55 "fmt"
6 "os/exec"
76 "os"
7 "os/exec"
88 "path/filepath"
99 "strings"
1010)
@@ -43,19 +43,19 @@ func GetUserInputFromRofi(message string) (string, error) {
4343 }
4444 // Create the Rofi command
4545 cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "userinput.rasi"), "-p", "Input", "-mesg", message)
46
46
4747 // Set up pipes for output
4848 var out bytes.Buffer
4949 cmd.Stdout = &out
50
50
5151 // Run the command
5252 err := cmd.Run()
5353 if err != nil {
5454 return "", fmt.Errorf("failed to run Rofi: %w", err)
5555 }
56
56
5757 // Get the entered input
5858 userInput := strings.TrimSpace(out.String())
59
59
6060 return userInput, nil
61}
\ No newline at end of file
61}
internal/unix_ipc.go +7 −7
@@ -4,13 +4,13 @@
44package internal
55
66import (
7 "net"
7 "net"
88)
99
1010func connectToPipe(ipcSocketPath string) (net.Conn, error) {
11 conn, err := net.Dial("unix", ipcSocketPath)
12 if err != nil {
13 return nil, err
14 }
15 return conn, nil
16}
\ No newline at end of file
11 conn, err := net.Dial("unix", ipcSocketPath)
12 if err != nil {
13 return nil, err
14 }
15 return conn, nil
16}