Author: johnnyg
Revision: 5607
Log:
Add support for cookies when adding a torrent by url.
Don't set torrent if torrentId is null.
Fix typo.
Diff:
Modified: trunk/deluge/ui/web/js/Deluge.Add.Url.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.Add.Url.js 2009-08-01 02:26:26 UTC (rev
5606)
+++ trunk/deluge/ui/web/js/Deluge.Add.Url.js 2009-08-01 02:38:30 UTC (rev
5607)
@@ -78,13 +78,14 @@
},
onAdd: function(field, e) {
- if (field.id == 'url' && e.getKey() != e.ENTER) return;
+ if ((field.id == 'url' || field.id == 'cookies') && e.getKey()
!= e.ENTER) return;
var field = this.urlField;
var url = field.getValue();
+ var cookies = this.cookieField.getValue();
var torrentId = this.createTorrentId();
- Deluge.Client.web.download_torrent_from_url(url, {
+ Deluge.Client.web.download_torrent_from_url(url, cookies, {
success: this.onDownload,
scope: this,
torrentId: torrentId
@@ -107,4 +108,4 @@
info['filename'] = request.options.filename;
this.fireEvent('add', request.options.torrentId, info);
}
-});
\ No newline at end of file
+});
Modified: trunk/deluge/ui/web/js/Deluge.Add.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.Add.js 2009-08-01 02:26:26 UTC (rev
5606)
+++ trunk/deluge/ui/web/js/Deluge.Add.js 2009-08-01 02:38:30 UTC (rev
5607)
@@ -270,6 +270,8 @@
},
setTorrent: function(torrentId) {
+ if (!torrentId) return;
+
this.torrentId = torrentId;
this.optionsManager.changeId(torrentId);
@@ -492,7 +494,7 @@
delete this.torrents[torrent.id];
this.grid.getStore().remove(torrent);
- this.options.clear();
+ this.optionsPanel.clear();
},
onSelect: function(selModel, rowIndex, record) {
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-08-01 02:26:26 UTC (rev 5606)
+++ trunk/deluge/ui/web/json_api.py 2009-08-01 02:38:30 UTC (rev 5607)
@@ -445,7 +445,7 @@
return main_deferred
@export
- def download_torrent_from_url(self, url):
+ def download_torrent_from_url(self, url, cookie=None):
"""
Download a torrent file from a url to a temporary directory.
@@ -457,7 +457,11 @@
tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1])
log.debug("filename: %s", tmp_file)
- return httpdownloader.download_file(url, tmp_file)
+ headers = {}
+ if cookie:
+ headers["Cookie"] = str(cookie)
+ log.debug("cookie: %s", cookie)
+ return httpdownloader.download_file(url, tmp_file, headers=headers)
@export
def get_torrent_info(self, filename):
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---