Rename .torrent file by idTorrent
This commit is contained in:
parent
a4e1fa8c3a
commit
aec8ad2b12
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"python.pythonPath": "/usr/bin/python3"
|
||||||
|
}
|
9
crawl.py
9
crawl.py
|
@ -49,6 +49,7 @@ def rollingFiles():
|
||||||
isDL()
|
isDL()
|
||||||
|
|
||||||
isDL()
|
isDL()
|
||||||
|
global idTorrent
|
||||||
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()
|
||||||
|
@ -103,7 +104,11 @@ def downloadTorrent():
|
||||||
# Download torrent file
|
# Download torrent file
|
||||||
if(scraper.login(login.user, login.passwd)):
|
if(scraper.login(login.user, login.passwd)):
|
||||||
print(colored("Login success", 'green'))
|
print(colored("Login success", 'green'))
|
||||||
|
subprocess.Popen('[[ $(ls data/tmp/torrents/) ]] && rm data/tmp/torrents/*', executable='/bin/bash')
|
||||||
scraper.download_from_torrent_url(research)
|
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:
|
else:
|
||||||
print(colored("Login failed", 'red'))
|
print(colored("Login failed", 'red'))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -115,8 +120,8 @@ def removeTracker():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Wait " + str(tkdelay) + " seconds to get peers before remove tracker...")
|
print("Wait " + str(tkdelay) + " seconds to get peers before remove tracker...")
|
||||||
time.sleep(tkdelay)
|
time.sleep(tkdelay)
|
||||||
os.popen('./trans-ctl.sh rmtracker ' + name).read()
|
os.popen('./trans-ctl.sh rmtracker ' + name)
|
||||||
os.popen('./trans-ctl.sh rmtracker ' + higherid).read()
|
os.popen('./trans-ctl.sh rmtracker ' + higherid)
|
||||||
# print(tkresult)
|
# print(tkresult)
|
||||||
|
|
||||||
rollingFiles()
|
rollingFiles()
|
||||||
|
|
|
@ -34,7 +34,7 @@ get_details() {
|
||||||
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)
|
||||||
FileName=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | tr -d '"}' | head -n1 | awk -F '/' '{ print $1 }')
|
FileName=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | tr -d '"}' | head -n1 | awk -F '/' '{ print $1 }')
|
||||||
FilesLocations="data/files/$FileName"
|
FilesLocations="data/files/$FileName"
|
||||||
TorrentLocation="data/torrents/$FileNameShort.torrent"
|
TorrentLocation="data/torrents/$idTorrent.torrent"
|
||||||
|
|
||||||
if [[ $Size =~ "Go" ]]; then
|
if [[ $Size =~ "Go" ]]; then
|
||||||
Unity="Go"
|
Unity="Go"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
tata = "187364"
|
||||||
|
|
||||||
|
os.popen(f'cd data/tmp/torrents/ && mv caca.torrent {tata}.torrent')
|
|
@ -329,7 +329,7 @@ class YggTorrentScraper:
|
||||||
return torrents
|
return torrents
|
||||||
|
|
||||||
#kopa
|
#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:
|
if torrent_url is not None:
|
||||||
torrent = self.extract_details(torrent_url)
|
torrent = self.extract_details(torrent_url)
|
||||||
|
|
||||||
|
@ -337,14 +337,14 @@ class YggTorrentScraper:
|
||||||
torrent_url=torrent.url, destination_path=destination_path
|
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:
|
if torrent is not None:
|
||||||
return self.download_from_torrent_download_url(
|
return self.download_from_torrent_download_url(
|
||||||
torrent_url=torrent.url, destination_path=destination_path
|
torrent_url=torrent.url, destination_path=destination_path
|
||||||
)
|
)
|
||||||
|
|
||||||
def download_from_torrent_download_url(
|
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:
|
if torrent_url is None:
|
||||||
raise Exception("Invalid torrent_url, make sure you are logged")
|
raise Exception("Invalid torrent_url, make sure you are logged")
|
||||||
|
|
Loading…
Reference in New Issue