support urls from add dialog
This commit is contained in:
parent
60d96c6f20
commit
62f6683730
|
@ -40,6 +40,7 @@ from twisted.internet import defer
|
|||
|
||||
from deluge.ui.client import client
|
||||
import deluge.component as component
|
||||
import deluge.common
|
||||
|
||||
from optparse import make_option
|
||||
import os,base64,glob
|
||||
|
@ -57,6 +58,11 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
|
|||
t_options["download_location"] = os.path.expanduser(options["path"])
|
||||
t_options["add_paused"] = options["add_paused"]
|
||||
|
||||
is_url = (not (options["path_type"]==1)) and (deluge.common.is_url(t_file) or options["path_type"]==2)
|
||||
|
||||
if is_url:
|
||||
files = [t_file]
|
||||
else:
|
||||
files = glob.glob(t_file)
|
||||
num_files = len(files)
|
||||
ress["total"] = num_files
|
||||
|
@ -65,6 +71,9 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
|
|||
fail_cb("Doesn't exist",t_file,ress)
|
||||
|
||||
for f in files:
|
||||
if is_url:
|
||||
client.core.add_torrent_url(f, t_options).addCallback(success_cb,f,ress).addErrback(fail_cb,f,ress)
|
||||
else:
|
||||
if not os.path.exists(f):
|
||||
fail_cb("Doesn't exist",f,ress)
|
||||
continue
|
||||
|
|
|
@ -463,6 +463,8 @@ class AllTorrents(BaseMode):
|
|||
self.popup.add_text_input("Enter path to torrent file:","file")
|
||||
self.popup.add_text_input("Enter save path:","path",dl)
|
||||
self.popup.add_select_input("Add Paused:","add_paused",["Yes","No"],[True,False],ap)
|
||||
self.popup.add_spaces(1)
|
||||
self.popup.add_select_input("Path is:","path_type",["Auto","File","URL"],[0,1,2],0)
|
||||
|
||||
def report_message(self,title,message):
|
||||
self.messages.append((title,message))
|
||||
|
|
Loading…
Reference in New Issue