Small suggestion: instead of hardcoding the .se domain, you might want to send a request to Wikidata to get the currently ised domains. That's how similar sci-hub tools do it to stay up-to-date.
I saw the shebang and still didn’t understand what the heck roku was.
Until I searched it:
“Raku is a member of the Perl family of programming languages. Formerly known as Perl 6, it was renamed in October 2019.”
I guess the rest API will do, ugh.
Related discussion: https://news.ycombinator.com/item?id=28277749
I made an iOS Shortcut based on the same code. To use it after installing, access it from the iOS Share screen when you're on a relevant site. It will look for preferred mirrors from Wikidata before running.
https://www.icloud.com/shortcuts/080b9f68c96a4491898b804547e...
Always review a Shortcut's actions before running it.