Page 1 of 1

*FIX* WebUI + Userscript

Posted: Sun Jun 07, 2009 9:36 am
by Znuff
Hi there.

I've been trying all day to fix the webui into accepting input from the userscript now that the function add_torrent_filecontent has been removed or has magically dissapeared somewhere. The fix takes less than a minute. Here's what you need to edit:

(take note, on my ubuntu box the webui files are under/usr/share/python-support/deluge-webui/deluge/ui/webui)

The original code in the file pages.py you need to find is:

Code: Select all

        if vars.data_b64: #b64 post (greasemonkey)
            data_b64 = unicode(vars.data_b64)
            torrent_name = vars.torrent_name
        else:  #file-post (curl)
            data_b64 = base64.b64encode(vars.torrent.file.read())
            torrent_name = vars.torrent.filename
        proxy.add_torrent_filecontent(torrent_name, data_b64)
        return 'ok'
Now, all you need to do is to change some lines around so the code reads:

Code: Select all

        if vars.data_b64: #b64 post (greasemonkey)
            data_b64 = base64.decodestring(unicode(vars.data_b64))
            torrent_name = vars.torrent_name
        else:  #file-post (curl)
            log.debug('testing')
            data_b64 = base64.b64encode(vars.torrent.file.read())
            torrent_name = vars.torrent.filename
        proxy.add_torrent_file_binary(torrent_name, data_b64)
So, we basically decode the b64 data then we replaced add_torrent_filecontents with add_torrent_file_binary.

Have fun with those torrents ;)

Re: *FIX* WebUI + Userscript

Posted: Mon Jun 08, 2009 4:39 am
by andar
Great. I will review and commit this fix to svn for 1.1.9.

Re: *FIX* WebUI + Userscript

Posted: Mon Jun 08, 2009 9:26 pm
by andar
This has been committed in revision 5361.

Re: *FIX* WebUI + Userscript

Posted: Tue Jun 16, 2009 9:10 pm
by micah.waldstein
Awesome! This fixes a long standing bug I opened - http://dev.deluge-torrent.org/ticket/670