Page 1 of 2

Deluge client for XBMC

Posted: Wed Jun 30, 2010 8:13 pm
by pramodbutte
Hi all,

I am trying to write a deluge client XBMC script to display the torrent status within XBMC.

I am trying to connect to the deluge daemon running locally, but cannot do so. Any help is appreciated I am posting a basic class I am building to connect to deluge daemon.

Code: Select all


#import xbmc
#import xbmcgui
from datetime import datetime
from deluge.common import ftime, fsize, fspeed
from deluge.ui.client import client
from twisted.internet import reactor
from optparse import OptionParser
import codecs
import logging
import os
import sys

class DelugeInfo:
    uri = None
    options = None
    sessionstate = None
    sessionstatefound = False

    STATE_DOWNLOADING = 4
    STATE_SEEDING = 3
    STATE_QUEUED = 2
    STATE_PAUSED = 1
    STATE_UNKNOWN = 0
        
    def __init__(self, options):
        self.options = options
        self.d = client.connect(host="127.0.0.1",port=58846,username="",password="")
        print self.d
        print client.connected()

def main():
    options = None
    delugeInfo = DelugeInfo(options)


if __name__ == '__main__':
    main()
    sys.exit()

when I run this code I get the output as:

print self.d outputs '<Deferred at 0x221be18>'
print client.connected() outputs 'False

and I do not get any server log where a connection attempt was made.

What am I doing wrong? Any help will be appreciated

Thank you

Edit:

I am using latest deluge 1.3.0_rc and python 2.6.
Eclipse ide with pyDev extension

Re: Deluge client for XBMC

Posted: Wed Jun 30, 2010 9:40 pm
by gazpachoking

Re: Deluge client for XBMC

Posted: Wed Jun 30, 2010 10:42 pm
by pramodbutte
Thank you for your quick reply! I actually have referred to the link before.
My problem is even after adding this code

Code: Select all

class DelugeInfo:
    uri = None
    options = None
    sessionstate = None
    sessionstatefound = False
    STATE_DOWNLOADING = 4
    STATE_SEEDING = 3
    STATE_QUEUED = 2
    STATE_PAUSED = 1
    STATE_UNKNOWN = 0
        
    def __init__(self, options):
        self.options = options
        d = client.connect(host="127.0.0.1",port=58846,username="",password="")
        print d
        d.addCallback(self.on_connect_success)
        d.addErrback(self.on_connect_fail)
        
    def on_connect_success(result):
        print "connected"
        print "result: ", result
        client.disconnect()
        reactor.stop()
        
    def on_connect_fail(result):
        print "failed"
        print "result: ", result
        pass
I have NO output on the console and my server log does not indicate any attempt from a client to connect.
Is there a specific package I need to install before the client.connect code will actually talk with the daemon running on the localhost?

Re: Deluge client for XBMC

Posted: Wed Jun 30, 2010 11:43 pm
by gazpachoking
I didn't look too closely at your code, but it looks like you need to start the reactor. The twisted calls and callbacks don't start going till you call reactor.run()

Re: Deluge client for XBMC

Posted: Wed Jun 30, 2010 11:47 pm
by pramodbutte
Yes... I had forgotten to start the reactor.

Again that you very much for your time. I really appreciate your help

Deluge and XBMC python version conflict

Posted: Sat Jul 03, 2010 3:19 am
by pramodbutte
I am trying to write a XBMC client for deluge. But the internal XBMC python interpreter used python 2.4 and the deluge + twisted uses python 2.6.
Currently when I run a the client using python 2.6 interpreter, it connects and gets information from the server. but the same client in XBMC does not connect.
does anyone know what would be the best way to work around this discrepancy?
Thank you!

Re: Deluge and XBMC python version conflict

Posted: Sat Jul 03, 2010 5:06 am
by johnnyg
Deluge requires python version 2.5 at least.
Is there no way to upgrade the internal python interpreter?

Re: Deluge and XBMC python version conflict

Posted: Sat Jul 03, 2010 9:09 pm
by pramodbutte
I think you can configure and build with python 2.6 interpreter, but then the script will not be distributable :(

Re: Deluge and XBMC python version conflict

Posted: Sat Jul 03, 2010 11:08 pm
by pramodbutte
Is there a specific library used by Deluge using python 2.5 which may work under python 2.4? an older version perhaps? e.g. twisted

Re: Deluge client for XBMC

Posted: Mon Jul 05, 2010 3:10 pm
by rflores2323
Im very interested in this as I use xbmc and would love to be able to see my torrent status thru xbmc.

let us know how the progress is coming along and PM me when its finished if possible. Im sure you going to advise the xbmc forums also if not I can.