fix(feeds): RSS improve torrent size parsing (#667)

* Fixes issue 636 - fail to parse torrent size on some RSS feeds when enclosure is a fixed value

* Pick the biggest size

* minor comment

* Updates release size when new parsed string size is bigger

- Sets default size of `Release` to zero (unparsed)
- When there are parsing errors, then it doesn't RESET the size to 0 (assuming a tracker providing some size that can't be parsed)
- Updates the size to the new size only if the parsed size is bigger than the previous.

* fix(feeds): ignore default 39399 enclosure size

---------

Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
Ignacio 2023-02-05 10:18:17 -08:00 committed by GitHub
parent c17034dcff
commit 9a47dbc588
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View file

@ -113,7 +113,7 @@ func (j *RSSJob) processItem(item *gofeed.Item) *domain.Release {
if e.Type == "application/x-bittorrent" && e.URL != "" {
rls.TorrentURL = e.URL
}
if e.Length != "" {
if e.Length != "" && e.Length != "39399" {
rls.ParseSizeBytesString(e.Length)
}
}
@ -154,11 +154,9 @@ func (j *RSSJob) processItem(item *gofeed.Item) *domain.Release {
rls.Uploader += v.Name
}
if rls.Size == 0 {
// parse size bytes string
if sz, ok := item.Custom["size"]; ok {
rls.ParseSizeBytesString(sz)
}
// When custom->size and enclosures->size differ, `ParseSizeBytesString` will pick the largest one.
if size, ok := item.Custom["size"]; ok {
rls.ParseSizeBytesString(size)
}
// additional size parsing