AddTorrentCheck

Suggest, post, or discuss plugins for Deluge
idiocracy
Leecher
Leecher
Posts: 76
Joined: Tue Jul 23, 2019 11:04 am

Re: AddTorrentCheck

Post by idiocracy »

This one works.
AddTorrentCheck-0.2-py2.7.egg
(12.82 KiB) Downloaded 287 times
Copy to "%appdata%\Roaming\deluge\plugins"
It is more similar to original, for some reason my changes didn't really work, but it still has a delay between runs to prevent it from running every sec or more which is overkill.

If you want something like that plugin because you're running your own seedbox or whatever.
Then you might also want this:
torrentmanager.7z
Deluge V1
(10.51 KiB) Downloaded 231 times
This is an edited "torrentmanager.pyc" where these values are changed from 3 min to 10 min.

Code: Select all

        # Save the state and resume data every ~3 minutes.
        self.save_state_timer.start(600, False)
        self.save_resume_data_timer.start(590, False)
Close deluge, unpack 7z and overwrite "C:\Program Files (x86)\Deluge\deluge-1.3.15-py2.7.egg\deluge\core\torrentmanager.pyc"
Last edited by idiocracy on Sat Nov 09, 2019 11:28 am, edited 7 times in total.
idiocracy
Leecher
Leecher
Posts: 76
Joined: Tue Jul 23, 2019 11:04 am

Re: AddTorrentCheck

Post by idiocracy »

Deluge 2.

Copy to "%appdata%\Roaming\deluge\plugins"
AddTorrentCheck-0.2-py3.6.egg
(12.62 KiB) Downloaded 244 times

"torrentmanager.py" with 20 min auto save instead of 3 min. Copy & overwrite "torrentmanager.py" in "C:\Program Files\Deluge2\Lib\site-packages\deluge\core\"
torrentmanager.7z
(11.84 KiB) Downloaded 185 times
Brightspark
New User
New User
Posts: 2
Joined: Sun Dec 15, 2019 7:05 am

Re: AddTorrentCheck

Post by Brightspark »

Just wanted to add my little (probably messy) python script that i use with the Execute plugin with the Torrent Added option. Make sure you chmod +x the file for it to work.
I have not tested this on windows but can't see anything in the code that would make me think it wouldn't be compatible.

Code: Select all

#!/usr/bin/python3
import subprocess, sys, time
#Grab torrent ID from args passed by Deluge
id = sys.argv[1]
#use deluge-console to get info on the added torrent, no connect argument needed if getting info from local daemon.
proc = subprocess.check_output(["deluge-console","info "+id+" -v"]).decode("utf8").strip()
#grab the number of peers from the torrent
proc = int(proc[proc.find("Peers: ")+7:proc.find(" ",proc.find("Peers: ")+7)])
#Pause, Resume and Update tracker until peers reachers more than 1. Sleep timers between can be altered if needed.
while proc <= 1:
        subprocess.run(["deluge-console","pause "+id])
        time.sleep(2)
        subprocess.run(["deluge-console","resume "+id])
        time.sleep(4)
        subprocess.run(["deluge-console","update_tracker "+id])
        proc = subprocess.check_output(["deluge-console","info "+id+" -v"]).decode("utf8").strip()
        proc = int(proc[proc.find("Peers: ")+7:proc.find(" ",proc.find("Peers: ")+7)])
#uncomment the below lines if you want to create an output to text file to verify if you have it setup right.
#with open("test.txt","a+") as f:
#       f.write(id + " : workededed\n")
exit()
Hope this helps.
Brightspark
New User
New User
Posts: 2
Joined: Sun Dec 15, 2019 7:05 am

Re: AddTorrentCheck

Post by Brightspark »

or another way, works better than calling deluge-console over and over using deluge-client package.

deluge-client (https://github.com/JohnDoee/deluge-client)
pip3 install deluge-client

Code: Select all

#!/usr/bin/python3
import time,sys
from deluge_client import DelugeRPCClient

tID = sys.argv[1]
dHost = "127.0.0.1"
dPort = 58846
dUser = "user"
dPass = "pass"

client = DelugeRPCClient(dHost,dPort,dUser,dPass)
client.connect()
while client.connected == False:
        time.sleep(3)
        client = DelugeRPCClient(dHost,dPort,dUser,dPass)
        client.connect()

time.sleep(3)
tData = client.call('core.get_torrent_status',tID,{})
while tData[b'state'] == b'Downloading' or tData[b'state'] == b'Paused':
        if len(tData[b'peers']) < 2:
                client.call('core.pause_torrent',tID)
                time.sleep(1)
                client.call('core.resume_torrent',tID)
                time.sleep(2)
                client.call('core.force_reannounce',[tID])
                time.sleep(3)
                tData = client.call('core.get_torrent_status',tID,{})
        else:
                exit()
exit()
add your client details in the vars, add as to Execute plugin under Torrent Added. Script will run and check number of peers while state of the torrent is "Downloading". If peers is less than 2 while in this state it will pause, resume and recheck the state and number of peers and repeat until either the torrent state changes or the number of peers has been met.

Very simple to help with the unrecognised torrent error with private trackers used with autodl-irssi.
idiocracy
Leecher
Leecher
Posts: 76
Joined: Tue Jul 23, 2019 11:04 am

Re: AddTorrentCheck

Post by idiocracy »

idiocracy wrote: Fri Nov 08, 2019 2:56 pm Deluge 2.

Copy to "%appdata%\Roaming\deluge\plugins"
AddTorrentCheck-0.2-py3.6.egg


"torrentmanager.py" with 20 min auto save instead of 3 min. Copy & overwrite "torrentmanager.py" in "C:\Program Files\Deluge2\Lib\site-packages\deluge\core\"
torrentmanager.7z
When python version is updated, ie: 3.8 and now 3.9. Remember to rename the plugin file to match the version ie: if using deluge with python version 3.9, rename to "AddTorrentCheck-0.2-py3.9.egg".
Otherwise it'll stop working.
Post Reply