From 84ed0186f67df1e2133e87597df608d78cf92a02 Mon Sep 17 00:00:00 2001 From: bugswriter Date: Sun, 3 Jan 2021 02:37:47 +0530 Subject: [PATCH] README update --- README.md | 25 +++++++++++++++++++- pirokit | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 pirokit diff --git a/README.md b/README.md index d495b18..f67ca56 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# pirokit +# Pirokit + +This script is used to web scrape a very popular torrent site 1337x.to to search torrents using bash, and you can represent scrapped torrent data in fzf / dmenu / rofi sort of like menu to select which torrent to download. + +## Installation + +Place this script where you keep your scripts. + +```bash +chmod +x pirokit +``` + +## Usage +``` +pirokit "search query" +``` +or if you use without search query it's by default going to ask take input with dmenu. + + +## 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 new file mode 100755 index 0000000..0ce2f9f --- /dev/null +++ b/pirokit @@ -0,0 +1,68 @@ +#!/usr/bin/bash + +mkdir -p $HOME/.cache/pirokit + +if [ -z $1 ]; then + query=$(echo "" | dmenu -p "Search Torrent: ") +else + query=$1 +fi + +baseurl="https://1337x.to" +cachedir="$HOME/.cache/pirokit" +query="$(sed 's/ /+/g' <<<$query)" + +#curl -s https://1337x.to/category-search/$query/Movies/1/ > $cachedir/tmp.html +curl -s https://1337x.to/search/$query/1/ > $cachedir/tmp.html + +# Get Titles +grep -o '' $cachedir/tmp.html | + sed 's/<[^>]*>//g' | sed 'N;s/\n/ /' > $cachedir/seedleech.bw + +# Size +grep -o '.*<\/span>//g' | + sed -e 's/<[^>]*>//g' > $cachedir/size.bw + +# Links +grep -E '/torrent/' $cachedir/tmp.html | + sed -E 's#.*(/torrent/.*)/">.*/#\1#' | + sed 's/td>//g' > $cachedir/links.bw + + + +# Clearning up some data to display +sed 's/\./ /g; s/\-/ /g' $cachedir/titles.bw | + sed 's/[^A-Za-z0-9 ]//g' | tr -s " " > $cachedir/tmp && mv $cachedir/tmp $cachedir/titles.bw + +awk '{print NR " - ["$0"]"}' $cachedir/size.bw > $cachedir/tmp && mv $cachedir/tmp $cachedir/size.bw +awk '{print "[S:"$1 ", L:"$2"]" }' $cachedir/seedleech.bw > $cachedir/tmp && mv $cachedir/tmp $cachedir/seedleech.bw + +# Getting the line number +LINE=$(paste -d\ $cachedir/size.bw $cachedir/seedleech.bw $cachedir/titles.bw | + dmenu -i -l 25 | + cut -d\- -f1 | + awk '{$1=$1; print}') + +url=$(head -n $LINE $cachedir/links.bw | tail -n +$LINE) +fullURL="${baseurl}${url}/" + +# Requesting page for magnet link +curl -s $fullURL > $cachedir/tmp.html +magnet=$(grep -Po "magnet:\?xt=urn:btih:[a-zA-Z0-9]*" $cachedir/tmp.html | head -n 1) + +deluge-console add "$magnet" + +# Simple notification +notify-send "⬇️ Start downloading File 📁"