diff --git a/README.md b/README.md index f67ca56..cd75274 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,3 @@ or if you use without search query it's by default going to ask take input with ## Contributing 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/) diff --git a/pirokit b/pirokit index 3b5e4a0..a1d3b16 100755 --- a/pirokit +++ b/pirokit @@ -16,12 +16,41 @@ list() { 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/" -#get query from dmenu -query=$(printf '%s' "" | dmenu -i -p "Search Torrent:" | sed 's/ /+/g') +prompt="fzf" -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" ;; Movies) search_url="$baseurl/category-search/$query/Movies" ;; TV) search_url="$baseurl/category-search/$query/TV" ;; @@ -54,7 +83,7 @@ while true; do #gets line number (that groupthe user selected in dmenu) 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