From ea94ab06ea044c025bf583153c3f6e02beaac49b Mon Sep 17 00:00:00 2001 From: poka Date: Sat, 21 Mar 2020 06:50:14 +0100 Subject: [PATCH] Get db value from crawl.py and fix checkdisk with good values --- crawl.py | 22 +++++++++++++++++----- lib/scrabash.sh | 8 +++++++- trans-ctl.sh | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/crawl.py b/crawl.py index d84feac..ba7b869 100755 --- a/crawl.py +++ b/crawl.py @@ -39,13 +39,25 @@ except ValueError: True else: sys.exit(1) -if displayDetails == "true": - detail = subprocess.call(["lib/scrabash.sh", "get_details", research]) -#torrentSize = +idTorrent = os.popen('./lib/scrabash.sh get_details ' + research).read() +dbPath = "./data/nfo/{}/db.py".format(idTorrent.rstrip()) +torrentDB = os.popen('cat ' + dbPath).read() -diskSize = subprocess.call(["./trans-ctl.sh", "checkdisk"]) -if diskSize >= 15: +print(torrentDB) +print("---") + +torrentDBFile = open(dbPath, "r") + +for line in torrentDBFile: + if re.search("Size", line): + fields = line.strip().split() + torrentSize = float(fields[2]) #kopa + +diskSize = os.popen('./trans-ctl.sh checkdisk').read() +#print(diskSize) +diskEnd = float(diskSize) + torrentSize +if diskEnd >= 15: print("You have filled the entire space allocated to torrents: " + diskSize) sys.exit("Disk full") diff --git a/lib/scrabash.sh b/lib/scrabash.sh index 289e496..5b21cec 100755 --- a/lib/scrabash.sh +++ b/lib/scrabash.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Config +print=true + name="${@:2}" nameR=$(echo $name | sed -e 's/[^ ]*=[^ ]*//ig') @@ -34,11 +37,14 @@ get_details() { 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" > ./data/nfo/$idTorrent/db.py +Seeders = $torrentSeeders +ID = $idTorrent" > ./data/nfo/$idTorrent/db.py fi } diff --git a/trans-ctl.sh b/trans-ctl.sh index d70560f..1f39d21 100755 --- a/trans-ctl.sh +++ b/trans-ctl.sh @@ -39,7 +39,7 @@ getid() { checkdisk() { diskSize=$(du -hs data/files/ | awk '{ print $1 }') [[ $diskSize =~ "G" ]] && diskSize=$(echo $diskSize | tr -d 'G') || return 0 - [[ "$diskSize" -ge "$diskLimit" ]] && echo "You have reached the maximum space allocated to torrents: $diskSize" + [[ "$diskSize" -ge "$diskLimit" ]] && echo "You have reached the maximum space allocated to torrents: $diskSize" || echo "$diskSize" | tr ',' '.' } case "$1" in