fix(feeds): always upgrade size from RSS description (#1458)

* fix(rss): add additional test for size

* always upgrade from desc
This commit is contained in:
Kyle Sanderson 2024-03-19 09:06:49 -07:00 committed by GitHub
parent 93538d0254
commit d86b2333a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

@ -210,11 +210,9 @@ func (j *RSSJob) processItem(item *gofeed.Item) *domain.Release {
if item.Description != "" { if item.Description != "" {
rls.Description = item.Description rls.Description = item.Description
if rls.Size == 0 {
readSizeFromDescription(item.Description, rls) readSizeFromDescription(item.Description, rls)
j.Log.Trace().Msgf("Set new size %d from description", rls.Size) j.Log.Trace().Msgf("Set new size %d from description", rls.Size)
} }
}
// add cookie to release for download if needed // add cookie to release for download if needed
if j.Feed.Cookie != "" { if j.Feed.Cookie != "" {

View file

@ -269,6 +269,11 @@ func Test_readSizeFromDescription(t *testing.T) {
str: "<strong>Uploaded</strong>: 38B minutes ago<br>Size: 32GB", str: "<strong>Uploaded</strong>: 38B minutes ago<br>Size: 32GB",
want: "32GB", want: "32GB",
}, },
{
name: "upgrade size",
str: `<p> <strong>Name</strong>: One.S01E01.German.DL.DTS.1080p.BluRay.x265.10bit-Cats<br> <strong>Category</strong>: Anime Serien<br> <strong>Type</strong>: Encode<br> <strong>Resolution</strong>: 1080p<br> <strong>Size</strong>: 2.49 GiB<br> <strong>Uploaded</strong>: vor 3 Minuten<br> <strong>Seeders</strong>: 1 | <strong>Leechers</strong>: 7 | <strong>Completed</strong>: 0<br> <strong>Uploader</strong>: Hochgeladen von xxx <br> IMDB Link:<a href="https://anon.to?http://www.imdb.com/title/tt1" target="_blank">tt1</a><br> TMDB Link: <a href="https://anon.to?https://www.themoviedb.org/tv/1" target="_blank">1</a><br> </p>`,
want: "2.49GiB",
},
} }
for _, tt := range tests { for _, tt := range tests {