123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #!/bin/bash
- filter_list="none
- noremakes
- trusted"
- category_list="all
- anime
- anime_mv
- anime_englis
- anime_other
- anime_raw
- audio
- lossless
- lossy
- literature
- literature_english
- literature_other
- literature_raw
- live_action
- live_action_english
- live_action_pv
- live_action_other
- live_action_raw
- picture
- graphic
- photo
- software
- apps
- games
- art
- art_anime
- art_doujin
- art_games
- art_manga
- art_pictures
- real_life
- real_life_pictures
- real_life_videos"
- filter="none"
- category="all"
- page=1
- instance="https://nyaa.si"
- select=""
- while true; do
- case $(printf "search\nchoose filter\nchoose category\nchoose instance\n" | dmenu "$@" -p "Nyaash: ") in
- "search")
- break
- ;;
- "choose filter")
- user_filter="$(printf "%s\n" "$filter_list" | dmenu "$@" -p "(Nyaash) Pick category")"
- if [ -n "$user_filter" ]; then
- category="$user_filter"
- fi
- ;;
- "choose category")
- user_category="$(printf "%s\n" "$category_list" | dmenu "$@" -p "(Nyaash) Pick category")"
- if [ -n "$user_category" ]; then
- category="$user_category"
- fi
- ;;
- "choose instance")
- case $(printf "https://nyaa.si\nhttps://sukebei.nyaa.si\ncustom" | dmenu "$@" -p "(Nyaash) instance: ") in
- "https://nyaa.si")
- instance="https://nyaa.si"
- ;;
- "https://sukebei.nyaa.si")
- instance="https://sukebei.nyaa.si"
- ;;
- "custom")
- custom_instance="$(echo "" | dmenu "$@" -p "(Nyaash) Custom Instance: ")"
- if [ -n "$custom_instance"]; then
- instance="$custom_instance"
- fi
- ;;
- *)
- ;;
- esac
- ;;
- *)
- exit 0
- ;;
- esac
- done
- query=$(echo "" | dmenu "$@" -p "(Nyaash) Search: ")
- declare -A items
- index=()
- while true; do
- page2="-p $page"
- output=$(nyaash "$query" -t $category -f $filter -i "$instance" -p $page)
- i=0
- itemname=""
- unset lines
- readarray lines = < <(echo "$output")
- for line in ${!lines[@]}; do
- case $(expr $line % 5) in
- 0)
- itemname="$(printf '%s\n' "${lines[$line]}" | sed 's/^[0-9]* //')"
- items["$itemname"]=""
- index[$i]="$itemname"
- i=$(($i+1))
- ;;
- 1)
- items["$itemname"]="${lines[$line]}"
- ;;
- esac
- done
- if [ $page -eq 1 ]; then
- selected="$(echo -e "next page\n$(printf "%s\n" "${index[@]})")" | dmenu "$@" -p "(Nyaash) Download: ")"
- else
- selected="$(echo -e "next page\nprevious page\n$(printf "%s\n" "${index[@]})")" | dmenu "$@" -p "(Nyaash) Download: ")"
- fi
- case "$selected" in
- "next page")
- page=$(( page + 1))
- ;;
- "previous page")
- page=$(( page - 1))
- ;;
- *)
- break
- ;;
- esac
- done
- xdg-open "${items["$selected"]}"
|