fix(feeds): parse magnet URI from enclosure (#1514)

fix(feeds): parse magnet from enclosure
This commit is contained in:
ze0s 2024-04-19 14:05:28 +02:00 committed by GitHub
parent ce17292573
commit 56aa7dd5cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import (
"net/url"
"regexp"
"strconv"
"strings"
"time"
"github.com/autobrr/autobrr/internal/domain"
@ -133,9 +134,16 @@ func (j *RSSJob) processItem(item *gofeed.Item) *domain.Release {
if e.Type == "application/x-bittorrent" && e.URL != "" {
rls.DownloadURL = e.URL
}
if e.Length != "" && e.Length != "39399" {
if e.Length != "" && e.Length != "1" && e.Length != "39399" {
rls.ParseSizeBytesString(e.Length)
}
if j.Feed.Settings != nil && j.Feed.Settings.DownloadType == domain.FeedDownloadTypeMagnet {
if !strings.HasPrefix(rls.MagnetURI, "magnet:?") && strings.HasPrefix(e.URL, "magnet:?") {
rls.MagnetURI = e.URL
rls.DownloadURL = ""
}
}
}
if rls.DownloadURL == "" && item.Link != "" {