Author: damoxc
Revision: 4912
Log:
implement basic adding of torrents via url
Diff:
Modified: trunk/deluge/ui/web/js/deluge-add.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-add.js 2009-03-21 12:02:18 UTC (rev
4911)
+++ trunk/deluge/ui/web/js/deluge-add.js 2009-03-21 12:28:48 UTC (rev
4912)
@@ -22,12 +22,30 @@
*/
Deluge.Add = {
+ torrents: new Hash(),
+
+ onAdd: function() {
+ torrents = new Array();
+ this.torrents.each(function(info, hash) {
+ torrents.include({
+ path: info['filename'],
+ options: {}
+ });
+ });
+ Deluge.Client.web.add_torrents(torrents, {
+ onSuccess: function(result) {
+ }
+ })
+ this.Window.hide();
+ },
+
onRender: function(window) {
},
onTorrentAdded: function(info) {
this.Store.loadData([[info['info_hash'], info['name']]], true);
+ this.torrents[info['info_hash']] = info;
},
onUrl: function(button, event) {
@@ -181,12 +199,11 @@
Deluge.Add.Url.Window = new Ext.Window({
layout: 'fit',
- width: 300,
- height: 150,
+ width: 350,
+ height: 115,
bodyStyle: 'padding: 10px 5px;',
buttonAlign: 'center',
closeAction: 'hide',
- closable: false,
modal: true,
plain: true,
title: _('Add from Url'),
@@ -214,7 +231,9 @@
buttons: [{
text: _('Cancel')
}, {
- text: _('Add')
+ text: _('Add'),
+ handler: Deluge.Add.onAdd,
+ scope: Deluge.Add
}],
listeners: {'render': {fn: Deluge.Add.onRender, scope: Deluge.Add}}
});
\ No newline at end of file
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-03-21 12:02:18 UTC (rev 4911)
+++ trunk/deluge/ui/web/json_api.py 2009-03-21 12:28:48 UTC (rev 4912)
@@ -24,6 +24,7 @@
import os
import time
+import base64
import urllib
import hashlib
import logging
@@ -357,8 +358,10 @@
"""
for torrent in torrents:
filename = os.path.basename(torrent["path"])
- fdump = open(torrent["path"], "r").read()
- client.add_torrent_file(filename, fdump, torrent["options"])
+ fdump = base64.encodestring(open(torrent["path"], "r").read())
+ log.info("Adding torrent from file `%s` with options `%r`",
+ filename, torrent["options"])
+ client.core.add_torrent_file(filename, fdump, torrent["options"])
d = Deferred()
d.callback(True)
return d
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---