diff --git a/deluge/ui/web/js/Deluge.Add.Url.js b/deluge/ui/web/js/Deluge.Add.Url.js index 56d39adc2..acfdf79af 100644 --- a/deluge/ui/web/js/Deluge.Add.Url.js +++ b/deluge/ui/web/js/Deluge.Add.Url.js @@ -78,13 +78,14 @@ Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, { }, 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 @@ Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, { info['filename'] = request.options.filename; this.fireEvent('add', request.options.torrentId, info); } -}); \ No newline at end of file +}); diff --git a/deluge/ui/web/js/Deluge.Add.js b/deluge/ui/web/js/Deluge.Add.js index e9ffb9205..d4d8b6439 100644 --- a/deluge/ui/web/js/Deluge.Add.js +++ b/deluge/ui/web/js/Deluge.Add.js @@ -270,6 +270,8 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { }, setTorrent: function(torrentId) { + if (!torrentId) return; + this.torrentId = torrentId; this.optionsManager.changeId(torrentId); @@ -492,7 +494,7 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, { delete this.torrents[torrent.id]; this.grid.getStore().remove(torrent); - this.options.clear(); + this.optionsPanel.clear(); }, onSelect: function(selModel, rowIndex, record) { diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 57c1adbaf..209ae9a59 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -445,7 +445,7 @@ class WebApi(JSONComponent): 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 @@ class WebApi(JSONComponent): 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):