78 lines
2.6 KiB
Bash
Executable File
78 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
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/"
|
|
|
|
#get query from dmenu
|
|
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) 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
|
|
tmp=$(curl -s "$search_url"/$page/)
|
|
#get titles
|
|
titles=$(printf '%s\n' "$tmp" | sed -nE "s/.*<a href=\"\/torrent\/.*\">([^>]*)<.*/\1/p")
|
|
#get seeders
|
|
seeders=$(printf "%s\n" "$tmp" | sed -nE "s/.*<td class=\"coll-2 seeds\">([^>]*)<.*/\1/p")
|
|
#get leechers
|
|
leeches=$(printf "%s\n" "$tmp" | sed -nE "s/.*<td class=\"coll-3 leeches\">([^>]*)<.*/\1/p")
|
|
#get sizes
|
|
sizes=$(printf "%s\n" "$tmp" | sed -nE "s/.*<td class=\"coll-4 size mob-uploader\">([^>]*)<.*/\1/p")
|
|
#get uploaders
|
|
uploaders=$(printf "%s\n" "$tmp" | sed -nE "s/.*<td class=\"coll-5 uploader\"><a href=.*>([^>]*)<.*/\1/p")
|
|
#get links
|
|
links=$(printf "%s\n" "$tmp" | sed -nE "s/.*<a href=\"(\/torrent\/[^>]*)\">.*/\1/p")
|
|
|
|
#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)
|
|
|
|
[ "$LINE" = "next" ] && page=$((page += 1)) && continue
|
|
|
|
[ "$LINE" = "previous" ] && page=$((page -= 1)) && continue
|
|
|
|
if [ -z "$LINE" ]; then exit; else break; fi
|
|
done
|
|
|
|
suburl=$(printf '%s\n' "$links" | sed -n "${LINE}p")
|
|
url="$baseurl$suburl"
|
|
|
|
site=$(curl -s "$url")
|
|
|
|
#scrape magnet link
|
|
magnet=$(printf '%s\n' "$site" | sed -nE "s/.*<a class=\".*\" href=\"(magnet[^>]*)\" onclick=.*/\1/p")
|
|
|
|
transmission-remote -a "$magnet"
|
|
|
|
#notify the user that the download has started
|
|
quick-notify "Pirokit" "Download Started"
|