Commit e1d6a35cf6

e1d6a35cf6a2f70e89368c0fbbbb88fff949c2a8

parent: 2b6d9e7f72

Unsigned

Wraient <wraient.911@gmail.com> · 2025-02-27 16:25 UTC

Fix: Only use sharepoint links for faster and quality playback

Layout: unified · split

internal/episode_url.go +18 −1
@@ -161,12 +161,29 @@ func GetEpisodeURL(config CurdConfig, id string, epNo int) ([]string, error) {
161 161
162 // Pre-count valid URLs and create slice to preserve order 162 // Pre-count valid URLs and create slice to preserve order
163 validURLs := make([]string, 0) 163 validURLs := make([]string, 0)
164 highestPriority := -1
165 var highestPriorityURL string
166
164 for _, url := range response.Data.Episode.SourceUrls { 167 for _, url := range response.Data.Episode.SourceUrls {
165 if len(url.SourceUrl) > 2 && unicode.IsDigit(rune(url.SourceUrl[2])) { 168 if len(url.SourceUrl) > 2 && unicode.IsDigit(rune(url.SourceUrl[2])) {
166 validURLs = append(validURLs, url.SourceUrl) 169 decodedURL := decodeProviderID(url.SourceUrl[2:])
170 if strings.Contains(decodedURL, LinkPriorities[0]) {
171 priority := int(url.SourceUrl[2] - '0')
172 if priority > highestPriority {
173 highestPriority = priority
174 highestPriorityURL = url.SourceUrl
175 }
176 } else {
177 validURLs = append(validURLs, url.SourceUrl)
178 }
167 } 179 }
168 } 180 }
169 181
182 // If we found a highest priority URL, use only that
183 if highestPriorityURL != "" {
184 validURLs = []string{highestPriorityURL}
185 }
186
170 if len(validURLs) == 0 { 187 if len(validURLs) == 0 {
171 return nil, fmt.Errorf("no valid source URLs found in response") 188 return nil, fmt.Errorf("no valid source URLs found in response")
172 } 189 }