#!/bin/bash # Config print=true name="${@:2}" nameR=$(echo $name | sed -e 's/[^ ]*=[^ ]*//ig') ## Get options args="${@:2}" [[ $args =~ "--best=true" ]] && best=true [[ $args =~ "--print=true" ]] && print=true search() { result=$(./lib/py/scrapactions.py $1 $name | jq .[] 2>&1 | tr -d '"') [[ $result =~ "parse error: Invalid " ]] && echo "$nameR: No torrent found" && err=1 && exit 1 [[ $best == true ]] && echo "$result" | head -n1 || echo "$result" } get_details() { result=$(./lib/py/scrapactions.py $1 $name | grep -v "Login success") # echo "$result" idTorrent=$(echo "$name" | awk -F '/' '{print $NF}' | awk -F '-' '{ print $1 }') if [[ $print == true ]]; then [[ ! -d data/nfo/$idTorrent ]] && mkdir data/nfo/$idTorrent echo "$result" > ./data/nfo/$idTorrent/info.txt torrentName=$(echo "$result" | grep -w "Name :" | awk -F ": " '{ print $2 }') torrentUrl=$(echo "$result" | grep -w "Url :" | awk -F ": " '{ print $2 }') torrentSize=$(echo "$result" | grep -w "Size :" | awk -F ": " '{ print $2 }') if [[ $torrentSize =~ "Go" ]]; then unity="Go" else unity="Mo" fi torrentSize=$(echo "$torrentSize" | tr -d 'Go') torrentSeeders=$(echo "$result" | grep -w "Seeders :" | awk -F ": " '{ print $2 }') echo "$idTorrent" echo "Name = '$torrentName' Url = '$torrentUrl' Size = $torrentSize Unity = '$unity' Seeders = $torrentSeeders ID = $idTorrent" > ./data/nfo/$idTorrent/db.py fi } $1 $1 [[ $err == 1 ]] && exit 1 || exit 0