Add fzf support.

This commit is contained in:
CronyAkatsuki 2023-11-03 22:16:05 +01:00
parent 7e63026018
commit 707afb4838
2 changed files with 33 additions and 7 deletions

View File

@ -19,6 +19,3 @@ or if you use without search query it's by default going to ask take input with
## Contributing ## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
[MIT](https://choosealicense.com/licenses/mit/)

37
pirokit
View File

@ -16,12 +16,41 @@ list() {
printf '%s\n%s' "next" "previous" printf '%s\n%s' "next" "previous"
} }
launcher() {
case "$1" in
"dmenu")
[ -z "$3" ] && dmenu -i -p "$2"
[ -n "$3" ] && dmenu -i -p "$2" -l "$3"
;;
"fzf")
fzf --reverse --prompt "$2"
;;
esac
}
baseurl="https://www.1377x.to/" baseurl="https://www.1377x.to/"
#get query from dmenu prompt="fzf"
query=$(printf '%s' "" | dmenu -i -p "Search Torrent:" | sed 's/ /+/g')
case "$(printf "All\\nMovies\\nTV\\nGames\\nMusic\\nApplications\\nDocumentaries\\nOther" | dmenu -i -p "Category to search in: ")" in #get query from dmenu
case "$1" in
"--dmenu")
prompt="dmenu"
query=$(printf '%s' "" | launcher $prompt "Search Torrent: " | sed 's/ /+/g')
;;
"")
printf '%s' "Search Torrent: "
read -r query
query=$(printf '%s\n' "$query" | sed 's/ /+/g')
;;
*)
query=$(printf '%s\n' "$1" | sed 's/ /+/g')
;;
esac
[ -z "$query" ] && exit
case "$(printf "All\\nMovies\\nTV\\nGames\\nMusic\\nApplications\\nDocumentaries\\nOther" | launcher $prompt "Category to search in: ")" in
All) search_url="$baseurl/search/$query" ;; All) search_url="$baseurl/search/$query" ;;
Movies) search_url="$baseurl/category-search/$query/Movies" ;; Movies) search_url="$baseurl/category-search/$query/Movies" ;;
TV) search_url="$baseurl/category-search/$query/TV" ;; TV) search_url="$baseurl/category-search/$query/TV" ;;
@ -54,7 +83,7 @@ while true; do
#gets line number (that groupthe user selected in dmenu) #gets line number (that groupthe user selected in dmenu)
LINE=$(list "$page" "$titles" "$uploaders" "$seeders" "$leeches" "$sizes" | LINE=$(list "$page" "$titles" "$uploaders" "$seeders" "$leeches" "$sizes" |
column -t -s '|' | dmenu -i -l 25 | cut -d- -f1) column -t -s '|' | launcher $prompt "Choose one to download" 25 | awk '{print $1}')
[ "$LINE" = "next" ] && page=$((page += 1)) && continue [ "$LINE" = "next" ] && page=$((page += 1)) && continue