Improve torrent research, remove tracker and externalize transmission ctl
This commit is contained in:
parent
0f2cf9f36d
commit
26d2596cda
25
crawl.py
25
crawl.py
|
@ -8,31 +8,36 @@
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
import subprocess
|
||||||
import login
|
import login
|
||||||
|
import time
|
||||||
|
|
||||||
# Load scraper
|
# Load scraper
|
||||||
from yggcrawl import YggTorrentScraper
|
from yggcrawl import YggTorrentScraper
|
||||||
scraper = YggTorrentScraper(requests.session())
|
scraper = YggTorrentScraper(requests.session())
|
||||||
from yggtorrentscraper import set_yggtorrent_tld
|
from yggtorrentscraper import set_yggtorrent_tld
|
||||||
set_yggtorrent_tld("se")
|
set_yggtorrent_tld("se")
|
||||||
name = sys.argv[1]
|
name = ' '.join(sys.argv[1:])
|
||||||
|
|
||||||
# Give paramaters to scraper
|
# Give paramaters to scraper
|
||||||
parameters = {
|
parameters = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"category": "films_&_videos",
|
"category": "films_&_videos",
|
||||||
"subcategory": "film",
|
"subcategory": "film",
|
||||||
"options": {
|
|
||||||
"langue": {"francais_(vff/truefrench)"},
|
|
||||||
},
|
|
||||||
"sort": "seed",
|
"sort": "seed",
|
||||||
"order": "desc"
|
"order": "desc"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute scrapping
|
# Execute scrapping
|
||||||
research = scraper.search(parameters)
|
research = scraper.search(parameters)
|
||||||
most_completed = scraper.most_completed()
|
|
||||||
|
|
||||||
|
# Check if not found
|
||||||
|
if research == []:
|
||||||
|
print("Aucun torrent trouvé ayant pour nom \"" + name + "\"")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
# Options
|
||||||
|
#most_completed = scraper.most_completed()
|
||||||
#print(json.dumps(research, sort_keys=True, indent=4))
|
#print(json.dumps(research, sort_keys=True, indent=4))
|
||||||
#print(json.dumps(most_completed, sort_keys=True, indent=4))
|
#print(json.dumps(most_completed, sort_keys=True, indent=4))
|
||||||
|
|
||||||
|
@ -43,3 +48,13 @@ if(scraper.login(login.user, login.passwd)):
|
||||||
scraper.download_from_torrent_url(first_torrent)
|
scraper.download_from_torrent_url(first_torrent)
|
||||||
else:
|
else:
|
||||||
print("Login failed")
|
print("Login failed")
|
||||||
|
|
||||||
|
# Remove tracker
|
||||||
|
|
||||||
|
print("Start to remove tracker ...")
|
||||||
|
time.sleep(1)
|
||||||
|
ID = subprocess.Popen(["./trans-ctl.sh -l | grep -vE 'Sum:|ID Done' | tail -n1 | awk '{ print $1 }'"], shell=True, executable="/bin/bash", stdout=subprocess.PIPE).communicate()[0].strip().decode('ascii')
|
||||||
|
print("Wait 10 seconds to get peers before remove tracker...")
|
||||||
|
time.sleep(10)
|
||||||
|
subprocess.call(["./trans-ctl.sh", "-t", ID, "--tracker-remove", "http://ygg.peer2peer.cc:8080"])
|
||||||
|
print("Done")
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
[[ -z $transUser ]] && transUser=$(grep "transUser" login.py | awk -F '=' '{ print $2 }' | tr -d '"' | tr -d ' ')
|
||||||
|
[[ -z $transPwd ]] && transPwd=$(grep "transPwd" login.py | awk -F '=' '{ print $2 }' | tr -d '"' | tr -d ' ')
|
||||||
|
|
||||||
|
#transmission-remote -t all --auth $transUser:$transPwd "$@"
|
||||||
|
transmission-remote --auth $transUser:$transPwd "$@"
|
Loading…
Reference in New Issue