a4k-openproject / script.module.openscrapers

OpenScrapers Project
GNU General Public License v3.0
102 stars 40 forks source link

Append 'size' key on torr sources #123

Closed host505 closed 4 years ago

host505 commented 4 years ago

...to make life easier of add-on devs on working with sizes (sort, limit etc)

reddit-reaper commented 4 years ago

hey @host505 can you explain the reasoning for your changes a bit more plz and thank you? :)

host505 commented 4 years ago

This adds a 'size' key on the infos that each torrent source carries. The value of that key should always be a floating point number (float()), corresponding to the fetched by the source size in GB. This makes it very easy for add-on devs to do stuff with sizes. Eg sorting their torrent sources results by size makes it almost a one-liner for exodus-based add-ons. Size filtering shouldn't be much harder as well.

Also, I noticed that the code that calculated sizes to GB was common for 25 out of 28 torrent sources (highly repeated), so I decided to turn that code to a function (_size) and use that instead. This function returns 2 values: size in float() and size in string format (with 2 decimals) . First one is to be used on the new 'size' key, second one is to be appended to the 'info' key.

reddit-reaper commented 4 years ago

ok thank you for your response. PR has been merged :)