Generic update.
This commit is contained in:
parent
15ecb794d7
commit
1c0a265455
5 changed files with 84 additions and 21 deletions
69
dmenu-rarbg
Executable file
69
dmenu-rarbg
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/sh
|
||||
|
||||
convert_sizes () {
|
||||
printf '%s\n' "$@" | \
|
||||
while read size; do
|
||||
numfmt --to iec --format "%.2f" $size
|
||||
done
|
||||
}
|
||||
|
||||
list() {
|
||||
num=1
|
||||
printf '%s\n' "$1" | \
|
||||
while read line in; do
|
||||
category=$(printf '%s' "$2" | sed -n "${num}p")
|
||||
seeder=$(printf '%s' "$3" | sed -n "${num}p")
|
||||
leecher=$(printf '%s' "$4" | sed -n "${num}p")
|
||||
size=$(printf '%s' "$5" | sed -n "${num}p")
|
||||
printf '%s\n' "$num - $line | $category | $seeder | $leecher | $size"
|
||||
num=$(($num + 1))
|
||||
done | column -t -s '|' | dmenu -i -l 15 | awk '{print $1}'
|
||||
}
|
||||
|
||||
query=$(printf '%s' | dmenu -i -p "Enter search term: " | sed 's/ /%20/g')
|
||||
|
||||
base_url="https://torrentapi.org/pubapi_v2.php?"
|
||||
|
||||
token=$(curl -sLH "User-agent: 'your bot 0.1'" "${base_url}get_token=get_token&app_id=pirokit" | jq -r '.token')
|
||||
|
||||
default_args="&token=${token}&limit=100&app_id=pirokit&format=json_extended"
|
||||
|
||||
|
||||
if [ "$query" = "" ]; then
|
||||
url="${base_url}mode=list${default_args}"
|
||||
else
|
||||
url="${base_url}mode=search&search_string=${query}$&sort=seeders${default_args}"
|
||||
fi
|
||||
|
||||
case "$(printf "All\\nMovies\\nTV Shows\\nGames\\nMusic" | dmenu -i -p "Choose category: ")" in
|
||||
All) response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}");;
|
||||
Movies) response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}&category=17;44;45;47;50;51;52;42;46;54");;
|
||||
"TV Shows") response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}&category=2;18;41;49");;
|
||||
Games) response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}&category=2;27;28;29;30;31;53");;
|
||||
Music) response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}&category=2;23;24;25;26");;
|
||||
esac
|
||||
|
||||
[ "$response" = "" ] && notify-send "RARBG" "Wait for 3 seconds for api to work." && exit 1
|
||||
[ "$response" = '{"error":"No results found","error_code":20}' ] && notify-send "RARBG" "No results found" && exit 1
|
||||
|
||||
# echo "$response" | jq '.'
|
||||
# exit 1
|
||||
|
||||
titles=$(printf '%s\n' "$response" | jq -r '.[] | .[].title')
|
||||
|
||||
seeders=$(printf '%s\n' "$response" | jq -r '.[] | .[].seeders')
|
||||
|
||||
leechers=$(printf '%s\n' "$response" | jq -r '.[] | .[].leechers')
|
||||
|
||||
sizes=$(convert_sizes "$(printf '%s\n' "$response" | jq -r '.[] | .[].size')")
|
||||
|
||||
magnets=$(printf '%s\n' "$response" | jq -r '.[] | .[].download')
|
||||
|
||||
categorys=$(printf '%s\n' "$response" | jq -r '.[] | .[].category')
|
||||
|
||||
number=$(list "$titles" "$categorys" "$seeders" "$leechers" "$sizes")
|
||||
[ "$number" = "" ] && exit
|
||||
|
||||
link=$(printf '%s\n' "$magnets" | sed -n "${number}p")
|
||||
|
||||
transmission-remote -a "$link" && notify-send "RARBG" "Downloading selected torrent."
|
Loading…
Add table
Add a link
Reference in a new issue