Created
October 20, 2022 15:39
-
-
Save palesz/90ca33654817ec004a4860cbe04d3324 to your computer and use it in GitHub Desktop.
Download from libgen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function libgen-url --description 'generate a libgen search url from the passed in string' | |
echo 'https://libgen.is/search.php?req='(string escape --style=url (string join ' ' $argv))'&lg_topic=libgen&open=0&view=simple&res=25&phrase=1&column=def' | |
end | |
function libgen | |
lynx (libgen-url $argv) | |
end | |
function libgen-download | |
set download_options (string split ' ' (curl -XGET (libgen-url $argv) 2>/dev/null | grep -o '<a.*\[1\]</a>' | grep -o 'http[^\'"]\+')) | |
echo "Found "(count $download_options)" download options for the query '"(echo $argv)"'" | |
for d in $download_options | |
echo "Extracting download url from $d" | |
set download_url (curl -XGET $d 2>/dev/null | grep -o '<a.*>GET</a>' | grep -o 'http[^\'"]\+') | |
set ipfs_download_url (curl -XGET $d 2>/dev/null | grep -o '<a.*IPFS.io</a>' | grep -o 'http[^\'"]\+' | grep 'ipfs.io') | |
echo "Downloading $download_url" | |
wget --content-disposition $ipfs_download_url || wget --content-disposition $download_url | |
echo "Throttling for 5 seconds" | |
sleep 5 | |
end | |
echo "Finished all the download options." | |
end | |
# Usage: libgen-download title of the book to download |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment