mirror of
https://github.com/codex-storage/deluge.git
synced 2025-03-03 12:30:45 +00:00
Add support for cookies when adding a torrent by url.
Don't set torrent if torrentId is null. Fix typo.
This commit is contained in:
parent
ded6bb9566
commit
9b0d4f6118
@ -78,13 +78,14 @@ Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onAdd: function(field, e) {
|
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 field = this.urlField;
|
||||||
var url = field.getValue();
|
var url = field.getValue();
|
||||||
|
var cookies = this.cookieField.getValue();
|
||||||
var torrentId = this.createTorrentId();
|
var torrentId = this.createTorrentId();
|
||||||
|
|
||||||
Deluge.Client.web.download_torrent_from_url(url, {
|
Deluge.Client.web.download_torrent_from_url(url, cookies, {
|
||||||
success: this.onDownload,
|
success: this.onDownload,
|
||||||
scope: this,
|
scope: this,
|
||||||
torrentId: torrentId
|
torrentId: torrentId
|
||||||
|
@ -270,6 +270,8 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setTorrent: function(torrentId) {
|
setTorrent: function(torrentId) {
|
||||||
|
if (!torrentId) return;
|
||||||
|
|
||||||
this.torrentId = torrentId;
|
this.torrentId = torrentId;
|
||||||
this.optionsManager.changeId(torrentId);
|
this.optionsManager.changeId(torrentId);
|
||||||
|
|
||||||
@ -492,7 +494,7 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
|||||||
|
|
||||||
delete this.torrents[torrent.id];
|
delete this.torrents[torrent.id];
|
||||||
this.grid.getStore().remove(torrent);
|
this.grid.getStore().remove(torrent);
|
||||||
this.options.clear();
|
this.optionsPanel.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect: function(selModel, rowIndex, record) {
|
onSelect: function(selModel, rowIndex, record) {
|
||||||
|
@ -445,7 +445,7 @@ class WebApi(JSONComponent):
|
|||||||
return main_deferred
|
return main_deferred
|
||||||
|
|
||||||
@export
|
@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.
|
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])
|
tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1])
|
||||||
log.debug("filename: %s", tmp_file)
|
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
|
@export
|
||||||
def get_torrent_info(self, filename):
|
def get_torrent_info(self, filename):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user