Change deluge config with a script

General support for problems installing or using Deluge
Post Reply
securpi

Change deluge config with a script

Post by securpi »

Hi,

since I use deluge behind a vpn I need to ask for portforwarding to my vpn provider in order to be able to receive incoming connections.
The problem is that the vpn provider gives me a different port every time I turn on the computer, therefore I am trying to create a script that:
- takes the port number as an input
- parse deluge config files to see its current incoming ports
- change to the new one if it is different

I tried using the json module in python but apparently it cannot read core.conf because of the initial lines

Code: Select all

{
  "file": 1, 
  "format": 1
}
How can I do it? Is there a simple way to accomplish this?
Thanks.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Change deluge config with a script

Post by Cas »

Simplest to use the deluge python modules:

Code: Select all

from deluge.config import Config
core_conf = Config('core.conf')
print(core_conf['listen_ports'])
core_conf['listen_ports'] = [1234, 1235]
print(core_conf['listen_ports'])
You could also use the deluge-console (non-interactive) to get and set values.
dukiethecorg
New User
New User
Posts: 4
Joined: Wed Jan 04, 2017 7:11 pm

Re: Change deluge config with a script

Post by dukiethecorg »

I did this for a Win7 Vm, the VPN IP and port would change on every connection. I found that changing the .conf file wasn't reliable, so I wrote a script to set the values using deluge-console. Hasn't failed me yet
Post Reply