Commit b698507701
Unsigned
Layout: unified · split
internal/curd.go +27
| @@ -979,6 +979,10 @@ func WriteTokenToFile(token string, filePath string) error { | ||
| 979 | 979 | |
| 980 | 980 | func StartCurd(userCurdConfig *CurdConfig, anime *Anime, logFile string) string { |
| 981 | 981 | |
| 982 | if anime.Ep.NextEpisode.Number == anime.Ep.Number { | |
| 983 | anime.Ep.Links = anime.Ep.NextEpisode.Links | |
| 984 | fmt.Println("using prefetched next episode link") | |
| 985 | } else { | |
| 982 | 986 | // Get episode link |
| 983 | 987 | link, err := GetEpisodeURL(*userCurdConfig, anime.AllanimeId, anime.Ep.Number) |
| 984 | 988 | if err != nil { |
| @@ -1008,6 +1012,7 @@ func StartCurd(userCurdConfig *CurdConfig, anime *Anime, logFile string) string | ||
| 1008 | 1012 | // anime.Ep.Links = link |
| 1009 | 1013 | } |
| 1010 | 1014 | anime.Ep.Links = link |
| 1015 | } | |
| 1011 | 1016 | |
| 1012 | 1017 | if len(anime.Ep.Links) == 0 { |
| 1013 | 1018 | CurdOut("No episode links found") |
| @@ -1016,6 +1021,28 @@ func StartCurd(userCurdConfig *CurdConfig, anime *Anime, logFile string) string | ||
| 1016 | 1021 | |
| 1017 | 1022 | Log(anime, logFile) |
| 1018 | 1023 | |
| 1024 | // Modify the goroutine in main.go where next episode links are fetched | |
| 1025 | // Get next episode link in parallel | |
| 1026 | go func() { | |
| 1027 | nextEpNum := anime.Ep.Number + 1 | |
| 1028 | if nextEpNum <= anime.TotalEpisodes { | |
| 1029 | // Get next canon episode number if filler skip is enabled | |
| 1030 | if userCurdConfig.SkipFiller && IsEpisodeFiller(anime.FillerEpisodes, anime.Ep.Number) { | |
| 1031 | nextEpNum = GetNextCanonEpisode(anime.FillerEpisodes, nextEpNum) | |
| 1032 | } | |
| 1033 | nextLinks, err := GetEpisodeURL(*userCurdConfig, anime.AllanimeId, nextEpNum) | |
| 1034 | if err != nil { | |
| 1035 | Log("Error getting next episode link: "+err.Error(), logFile) | |
| 1036 | } else { | |
| 1037 | anime.Ep.NextEpisode = NextEpisode{ | |
| 1038 | Number: nextEpNum, | |
| 1039 | Links: nextLinks, | |
| 1040 | } | |
| 1041 | Log(fmt.Sprintf("Next episode link fetched for ep %d", nextEpNum), logFile) | |
| 1042 | } | |
| 1043 | } | |
| 1044 | }() | |
| 1045 | ||
| 1019 | 1046 | // Write anime.AnilistId to curd_id in the storage path |
| 1020 | 1047 | idFilePath := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "curd_id") |
| 1021 | 1048 | Log(fmt.Sprintf("idFilePath: %v", idFilePath), logFile) |
internal/structs.go +6
| @@ -37,6 +37,7 @@ type Episode struct { | ||
| 37 | 37 | Started bool `json:"started"` |
| 38 | 38 | Duration int `json:"duration"` |
| 39 | 39 | Links []string `json:"links"` |
| 40 | NextEpisode NextEpisode `json:"next_episode"` | |
| 40 | 41 | IsFiller bool `json:"filler"` |
| 41 | 42 | IsRecap bool `json:"recap"` |
| 42 | 43 | Aired string `json:"aired"` |
| @@ -46,6 +47,11 @@ type Episode struct { | ||
| 46 | 47 | IsCompleted bool |
| 47 | 48 | } |
| 48 | 49 | |
| 50 | type NextEpisode struct { | |
| 51 | Number int | |
| 52 | Links []string | |
| 53 | } | |
| 54 | ||
| 49 | 55 | type playingVideo struct { |
| 50 | 56 | Url string |
| 51 | 57 | Speed float64 `json:"speed"` |