Update formatting.

This commit is contained in:
CronyAkatsuki 2023-11-04 22:03:43 +01:00
parent 41754e8ad1
commit e1c508c53b
16 changed files with 287 additions and 278 deletions

View file

@ -1,23 +1,23 @@
#!/bin/sh
convert_sizes () {
printf '%s\n' "$@" | \
while read size; do
numfmt --to iec --format "%.2f" $size
done
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}'
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}'
}
base_url="https://torrentapi.org/pubapi_v2.php?"
@ -25,9 +25,9 @@ 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=dmenu-rarbg" | jq -r '.token')
while [ "$token" = "" ]; do
token=$(curl -sLH "User-agent: 'your bot 0.1'" "${base_url}get_token=get_token&app_id=dmenu-rarbg" | jq -r '.token')
notify-send "RARGB" "Waiting 5 second for api limit to reset"
sleep 5
token=$(curl -sLH "User-agent: 'your bot 0.1'" "${base_url}get_token=get_token&app_id=dmenu-rarbg" | jq -r '.token')
notify-send "RARGB" "Waiting 5 second for api limit to reset"
sleep 5
done
default_args="&token=${token}&limit=100&app_id=dmenu-rarbg&format=json_extended"
@ -35,25 +35,25 @@ default_args="&token=${token}&limit=100&app_id=dmenu-rarbg&format=json_extended"
query=$(printf '%s' | dmenu -i -p "Enter search term: " | sed 's/ /%20/g')
if [ "$query" = "" ]; then
url="${base_url}mode=list${default_args}"
url="${base_url}mode=list${default_args}"
else
url="${base_url}mode=search&search_string=${query}$&sort=seeders${default_args}"
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) url="$url";;
Movies) url="${url}&category=17;44;45;47;50;51;52;42;46;54";;
"TV Shows") url="${url}&category=2;18;41;49";;
Games) url="${url}&category=2;27;28;29;30;31;53";;
Music) url="${url}&category=2;23;24;25;26";;
All) url="$url" ;;
Movies) url="${url}&category=17;44;45;47;50;51;52;42;46;54" ;;
"TV Shows") url="${url}&category=2;18;41;49" ;;
Games) url="${url}&category=2;27;28;29;30;31;53" ;;
Music) url="${url}&category=2;23;24;25;26" ;;
esac
response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}" )
response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}")
while [ "$response" = "" ]; do
response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}" )
notify-send "RARGB" "Waiting 5 second for api limit to reset"
sleep 5
response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}")
notify-send "RARGB" "Waiting 5 second for api limit to reset"
sleep 5
done
[ "$response" = "" ] && notify-send "RARBG" "Wait for 3 seconds for api to work." && exit 1