Closed drew2a closed 1 month ago
Yes, it is more verbose, but that is not necessarily a bad thing. More lines of code do not always equate to worse code.
It is more verbose because:
create_magnet
, which makes it possible to properly test it. The previous version did not allow this. trackers = [
tk['url'] for tk in self.current_download['trackers'] if 'url' in tk and tk['url'] not in ['[DHT]', '[PeX]']
]
was rewritten to:
invalid_urls = {'[DHT]', '[PeX]'}
urls = (t.get('url') for t in trackers)
valid_urls = [u for u in urls if u and u not in invalid_urls]
This makes it more understandable by splitting a large and complex expression into two expressions with clear purposes:
@kozlovsky, thank you for the review. I've addressed most of your comments except for the verbosity. For the explanation, please see above.
The function for copying the magnet link has been refactored. The code now is a bit safier.
Fixes #8016