diff --git a/pirokit b/pirokit index 071c430..3b5e4a0 100755 --- a/pirokit +++ b/pirokit @@ -1,76 +1,75 @@ -#!/usr/bin/env bash +#!/bin/sh -#ensures there are no accidental downloads -set -eo pipefail +list() { + num=1 + printf '%s\n' "$2" | + while read -r line; do + uploader=$(printf '%s' "$3" | sed -n "${num}p") + seeder=$(printf '%s' "$4" | sed -n "${num}p") + leecher=$(printf '%s' "$5" | sed -n "${num}p") + size=$(printf '%s' "$6" | sed -n "${num}p") + printf '%s\n' "$num - $line | $uploader | $seeder | $leecher | $size" + num=$((num + 1)) + done + # next and previous + [ "$1" = "1" ] && printf '%s\n' "next" || + printf '%s\n%s' "next" "previous" +} baseurl="https://www.1377x.to/" -cachedir="$HOME/.cache/dl" #get query from dmenu -query=$(printf '%s' | dmenu -i -p "Search Torrent:" | sed 's/ /+/g') - -#setup working dir -mkdir -p $cachedir -cd $cachedir +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 - All) url="$baseurl/search/$query" ;; - Movies) url="$baseurl/category-search/$query/Movies" ;; - TV) url="$baseurl/category-search/$query/TV" ;; - Games) url="$baseurl/category-search/$query/Games" ;; - Music) url"$baseurl/category-search/$query/Music" ;; - Applications) url="$baseurl/category-search/$query/Apps" ;; - Documentaries) url="$baseurl/category-search/$query/Documentaries" ;; - Other) url="$baseurl/category-search/$query/Other" ;; - *) exit ;; +All) search_url="$baseurl/search/$query" ;; +Movies) search_url="$baseurl/category-search/$query/Movies" ;; +TV) search_url="$baseurl/category-search/$query/TV" ;; +Games) search_url="$baseurl/category-search/$query/Games" ;; +Music) search_url"$baseurl/category-search/$query/Music" ;; +Applications) search_url="$baseurl/category-search/$query/Apps" ;; +Documentaries) search_url="$baseurl/category-search/$query/Documentaries" ;; +Other) search_url="$baseurl/category-search/$query/Other" ;; +*) exit ;; esac page=1 while true; do - # get the page html - curl -s $url/$page/ -o tmp.html + # get the page html + tmp=$(curl -s "$search_url"/$page/) + #get titles + titles=$(printf '%s\n' "$tmp" | sed -nE "s/.*([^>]*)<.*/\1/p") + #get seeders + seeders=$(printf "%s\n" "$tmp" | sed -nE "s/.*