Clear output crawler, add torrent location in db.py
This commit is contained in:
parent
189960d2a6
commit
736628ba27
6
crawl.py
6
crawl.py
|
@ -31,7 +31,6 @@ name = ' '.join(sys.argv[1:])
|
||||||
|
|
||||||
# Search torrent name
|
# Search torrent name
|
||||||
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
|
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
|
||||||
print(colored(research, 'yellow'))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
research.index("No torrent found")
|
research.index("No torrent found")
|
||||||
|
@ -53,8 +52,7 @@ def rollingFiles():
|
||||||
idTorrent = os.popen('./lib/scrabash.sh get_details ' + research).read()
|
idTorrent = os.popen('./lib/scrabash.sh get_details ' + research).read()
|
||||||
dbPath = "./data/meta/{}/db.py".format(idTorrent.rstrip())
|
dbPath = "./data/meta/{}/db.py".format(idTorrent.rstrip())
|
||||||
torrentDB = os.popen('cat ' + dbPath).read()
|
torrentDB = os.popen('cat ' + dbPath).read()
|
||||||
|
print(colored(torrentDB, 'blue'))
|
||||||
print(torrentDB)
|
|
||||||
print("---")
|
print("---")
|
||||||
|
|
||||||
torrentDBFile = open(dbPath, "r")
|
torrentDBFile = open(dbPath, "r")
|
||||||
|
@ -119,7 +117,7 @@ def removeTracker():
|
||||||
time.sleep(tkdelay)
|
time.sleep(tkdelay)
|
||||||
tkresult = os.popen('./trans-ctl.sh rmtracker ' + name).read()
|
tkresult = os.popen('./trans-ctl.sh rmtracker ' + name).read()
|
||||||
tkresult = os.popen('./trans-ctl.sh rmtracker ' + higherid).read()
|
tkresult = os.popen('./trans-ctl.sh rmtracker ' + higherid).read()
|
||||||
print(tkresult)
|
# print(tkresult)
|
||||||
|
|
||||||
rollingFiles()
|
rollingFiles()
|
||||||
downloadTorrent()
|
downloadTorrent()
|
||||||
|
|
|
@ -28,12 +28,13 @@ get_details() {
|
||||||
echo "$result" > info.txt
|
echo "$result" > info.txt
|
||||||
|
|
||||||
torrentName=$(echo "$result" | grep -w "Name :" | awk -F ": " '{ print $2 }')
|
torrentName=$(echo "$result" | grep -w "Name :" | awk -F ": " '{ print $2 }')
|
||||||
Url=$(echo "$result" | grep -w "Url :" | awk -F ": " '{ print $2 }')
|
Category=$(echo "$name" | awk -F '/' '{print $6}')
|
||||||
Size=$(echo "$result" | grep -w "Size :" | awk -F ": " '{ print $2 }')
|
Size=$(echo "$result" | grep -w "Size :" | awk -F ": " '{ print $2 }')
|
||||||
Uploader=$(echo "$result" | grep -w "Uploader :" | awk -F ": " '{ print $2 }')
|
Uploader=$(echo "$result" | grep -w "Uploader :" | awk -F ": " '{ print $2 }')
|
||||||
Files=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | wc -l)
|
Files=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | wc -l)
|
||||||
FilesNames=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | tr -d '"}')
|
FileName=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | tr -d '"}' | head -n1 | awk -F '/' '{ print $1 }')
|
||||||
FilesLocations="data/files/$FilesNames"
|
FilesLocations="data/files/$FileName"
|
||||||
|
TorrentLocation="data/torrents/$FileNameShort.torrent"
|
||||||
|
|
||||||
if [[ $Size =~ "Go" ]]; then
|
if [[ $Size =~ "Go" ]]; then
|
||||||
Unity="Go"
|
Unity="Go"
|
||||||
|
@ -45,7 +46,7 @@ get_details() {
|
||||||
|
|
||||||
echo "$idTorrent"
|
echo "$idTorrent"
|
||||||
|
|
||||||
echo -e "Name = '$torrentName'\nUrl = '$Url'\nSize = $Size\nUnity = '$Unity'\nID = $idTorrent\nUploader = $Uploader\nFiles = $Files\nFilesLocations = $FilesLocations" > db.py
|
echo -e "Name = $torrentName\nUrl = $name\nCategory = $Category\nSize = $Size\nUnity = $Unity\nID = $idTorrent\nUploader = $Uploader\nFiles = $Files\nFilesLocations = $FilesLocations\nTorrentLocation = $TorrentLocation" > db.py
|
||||||
|
|
||||||
# Get image
|
# Get image
|
||||||
[[ ! -d img ]] && mkdir img && cd img
|
[[ ! -d img ]] && mkdir img && cd img
|
||||||
|
|
13
trans-ctl.sh
13
trans-ctl.sh
|
@ -18,10 +18,12 @@ name="${@:2}"
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
getid() {
|
getid() {
|
||||||
|
# Check if no name, give last ID
|
||||||
if [[ -z $name ]]; then
|
if [[ -z $name ]]; then
|
||||||
result=$($transcmd --list | grep -vE 'Sum:|ID Done' | tail -n1 | awk '{ print $1 }')
|
result=$($transcmd --list | grep -vE 'Sum:|ID Done' | tail -n1 | awk '{ print $1 }')
|
||||||
elif [[ $name =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
|
elif [[ $name =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
|
||||||
result=$name
|
result=$name
|
||||||
|
# Get ID
|
||||||
else
|
else
|
||||||
j=0
|
j=0
|
||||||
for i in "$name"; do
|
for i in "$name"; do
|
||||||
|
@ -84,6 +86,17 @@ case "$1" in
|
||||||
remove)
|
remove)
|
||||||
idt=$(getid | tr -d '*')
|
idt=$(getid | tr -d '*')
|
||||||
if [[ $idt =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
|
if [[ $idt =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
|
||||||
|
for i in "$($transcmd --list | grep -vE 'Sum:|ID Done' )"; do
|
||||||
|
if [[ $(echo "$i" | awk '{ print $1 }') == $idt ]]; then
|
||||||
|
fileName=$(echo "$i" | awk '{ print $NF }')
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cd data/meta
|
||||||
|
torrentId=$(grep -r $fileName | head -n1 | awk -F '/' '{ print $1 }')
|
||||||
|
rm -rf $torrentId
|
||||||
|
|
||||||
$transcmd -t $idt --remove-and-delete > /dev/null && echo "Torrent $idt removed." || echo "Failed to remove $1"
|
$transcmd -t $idt --remove-and-delete > /dev/null && echo "Torrent $idt removed." || echo "Failed to remove $1"
|
||||||
else
|
else
|
||||||
echo "$idt"
|
echo "$idt"
|
||||||
|
|
Loading…
Reference in New Issue