Skip to content

Commit e1d6a35

Browse files
committed
Fix: Only use sharepoint links for faster and quality playback
1 parent 2b6d9e7 commit e1d6a35

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

internal/episode_url.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,29 @@ func GetEpisodeURL(config CurdConfig, id string, epNo int) ([]string, error) {
161161

162162
// Pre-count valid URLs and create slice to preserve order
163163
validURLs := make([]string, 0)
164+
highestPriority := -1
165+
var highestPriorityURL string
166+
164167
for _, url := range response.Data.Episode.SourceUrls {
165168
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+
}
167179
}
168180
}
169181

182+
// If we found a highest priority URL, use only that
183+
if highestPriorityURL != "" {
184+
validURLs = []string{highestPriorityURL}
185+
}
186+
170187
if len(validURLs) == 0 {
171188
return nil, fmt.Errorf("no valid source URLs found in response")
172189
}

0 commit comments

Comments
 (0)