From aec8ad2b1210bfc4d96899c1f9f51211f35de43c Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 26 Mar 2020 07:24:04 +0100 Subject: [PATCH] Rename .torrent file by idTorrent --- .vscode/settings.json | 3 +++ crawl.py | 9 +++++++-- lib/scrabash.sh | 2 +- tata.py | 7 +++++++ yggcrawl/yggtorrentscraper.py | 6 +++--- 5 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json create mode 100755 tata.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..615aafb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/bin/python3" +} \ No newline at end of file diff --git a/crawl.py b/crawl.py index 23260fb..dcd6cbe 100755 --- a/crawl.py +++ b/crawl.py @@ -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() diff --git a/lib/scrabash.sh b/lib/scrabash.sh index 740da47..df990cc 100755 --- a/lib/scrabash.sh +++ b/lib/scrabash.sh @@ -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" diff --git a/tata.py b/tata.py new file mode 100755 index 0000000..e22ad8a --- /dev/null +++ b/tata.py @@ -0,0 +1,7 @@ +#!/usr/bin/python3 + +import os + +tata = "187364" + +os.popen(f'cd data/tmp/torrents/ && mv caca.torrent {tata}.torrent') \ No newline at end of file diff --git a/yggcrawl/yggtorrentscraper.py b/yggcrawl/yggtorrentscraper.py index 182eec1..d9c0802 100644 --- a/yggcrawl/yggtorrentscraper.py +++ b/yggcrawl/yggtorrentscraper.py @@ -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")