Rename .torrent file by idTorrent

This commit is contained in:
poka 2020-03-26 07:24:04 +01:00
parent a4e1fa8c3a
commit aec8ad2b12
5 changed files with 21 additions and 6 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.pythonPath": "/usr/bin/python3"
}

View File

@ -49,6 +49,7 @@ def rollingFiles():
isDL()
isDL()
global idTorrent
idTorrent = os.popen('./lib/scrabash.sh get_details ' + research).read()
dbPath = "./data/meta/{}/db.py".format(idTorrent.rstrip())
torrentDB = os.popen('cat ' + dbPath).read()
@ -103,7 +104,11 @@ def downloadTorrent():
# Download torrent file
if(scraper.login(login.user, login.passwd)):
print(colored("Login success", 'green'))
subprocess.Popen('[[ $(ls data/tmp/torrents/) ]] && rm data/tmp/torrents/*', executable='/bin/bash')
scraper.download_from_torrent_url(research)
# os.popen(f'cd data/tmp/torrents/ && mv *.torrent {idTorrent}.torrent && mv *.torrent ../../torrents/')
os.popen(f'cd data/tmp/torrents/ && mv *.torrent {idTorrent.strip()}.torrent && mv {idTorrent.strip()}.torrent ../../torrents/')
else:
print(colored("Login failed", 'red'))
sys.exit(1)
@ -115,8 +120,8 @@ def removeTracker():
time.sleep(1)
print("Wait " + str(tkdelay) + " seconds to get peers before remove tracker...")
time.sleep(tkdelay)
os.popen('./trans-ctl.sh rmtracker ' + name).read()
os.popen('./trans-ctl.sh rmtracker ' + higherid).read()
os.popen('./trans-ctl.sh rmtracker ' + name)
os.popen('./trans-ctl.sh rmtracker ' + higherid)
# print(tkresult)
rollingFiles()

View File

@ -34,7 +34,7 @@ get_details() {
Files=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | wc -l)
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"
TorrentLocation="data/torrents/$idTorrent.torrent"
if [[ $Size =~ "Go" ]]; then
Unity="Go"

7
tata.py Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/python3
import os
tata = "187364"
os.popen(f'cd data/tmp/torrents/ && mv caca.torrent {tata}.torrent')

View File

@ -329,7 +329,7 @@ class YggTorrentScraper:
return torrents
#kopa
def download_from_torrent_url(self, torrent_url=None, destination_path="./data/torrents/"):
def download_from_torrent_url(self, torrent_url=None, destination_path="./data/tmp/torrents/"):
if torrent_url is not None:
torrent = self.extract_details(torrent_url)
@ -337,14 +337,14 @@ class YggTorrentScraper:
torrent_url=torrent.url, destination_path=destination_path
)
def download_from_torrent(self, torrent=None, destination_path="./data/torrents/"):
def download_from_torrent(self, torrent=None, destination_path="./data/tmp/torrents/"):
if torrent is not None:
return self.download_from_torrent_download_url(
torrent_url=torrent.url, destination_path=destination_path
)
def download_from_torrent_download_url(
self, torrent_url=None, destination_path="./data/torrents/"
self, torrent_url=None, destination_path="./data/tmp/torrents/"
):
if torrent_url is None:
raise Exception("Invalid torrent_url, make sure you are logged")