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
|
||||
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
|
||||
print(colored(research, 'yellow'))
|
||||
|
||||
try:
|
||||
research.index("No torrent found")
|
||||
|
@ -53,8 +52,7 @@ def rollingFiles():
|
|||
idTorrent = os.popen('./lib/scrabash.sh get_details ' + research).read()
|
||||
dbPath = "./data/meta/{}/db.py".format(idTorrent.rstrip())
|
||||
torrentDB = os.popen('cat ' + dbPath).read()
|
||||
|
||||
print(torrentDB)
|
||||
print(colored(torrentDB, 'blue'))
|
||||
print("---")
|
||||
|
||||
torrentDBFile = open(dbPath, "r")
|
||||
|
@ -119,7 +117,7 @@ def removeTracker():
|
|||
time.sleep(tkdelay)
|
||||
tkresult = os.popen('./trans-ctl.sh rmtracker ' + name).read()
|
||||
tkresult = os.popen('./trans-ctl.sh rmtracker ' + higherid).read()
|
||||
print(tkresult)
|
||||
# print(tkresult)
|
||||
|
||||
rollingFiles()
|
||||
downloadTorrent()
|
||||
|
|
|
@ -28,12 +28,13 @@ get_details() {
|
|||
echo "$result" > info.txt
|
||||
|
||||
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 }')
|
||||
Uploader=$(echo "$result" | grep -w "Uploader :" | awk -F ": " '{ print $2 }')
|
||||
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 '"}')
|
||||
FilesLocations="data/files/$FilesNames"
|
||||
FileName=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | tr -d '"}' | head -n1 | awk -F '/' '{ print $1 }')
|
||||
FilesLocations="data/files/$FileName"
|
||||
TorrentLocation="data/torrents/$FileNameShort.torrent"
|
||||
|
||||
if [[ $Size =~ "Go" ]]; then
|
||||
Unity="Go"
|
||||
|
@ -45,7 +46,7 @@ get_details() {
|
|||
|
||||
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
|
||||
[[ ! -d img ]] && mkdir img && cd img
|
||||
|
|
13
trans-ctl.sh
13
trans-ctl.sh
|
@ -18,10 +18,12 @@ name="${@:2}"
|
|||
# Functions
|
||||
|
||||
getid() {
|
||||
# Check if no name, give last ID
|
||||
if [[ -z $name ]]; then
|
||||
result=$($transcmd --list | grep -vE 'Sum:|ID Done' | tail -n1 | awk '{ print $1 }')
|
||||
elif [[ $name =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
|
||||
result=$name
|
||||
# Get ID
|
||||
else
|
||||
j=0
|
||||
for i in "$name"; do
|
||||
|
@ -84,6 +86,17 @@ case "$1" in
|
|||
remove)
|
||||
idt=$(getid | tr -d '*')
|
||||
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"
|
||||
else
|
||||
echo "$idt"
|
||||
|
|
Loading…
Reference in New Issue