From aa5da70030811c3f2b311bd437a69e7af788d594 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 1 Apr 2008 00:47:52 +0000 Subject: [PATCH] Implement Add by Url in the addtorrentdialog. --- TODO | 2 +- deluge/ui/gtkui/addtorrentdialog.py | 13 ++++++++++++- deluge/ui/gtkui/glade/main_window.glade | 1 - 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 438aaed7e..76d022c60 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,7 @@ For 0.6 release: * Update checking * Translations * Show proper priority levels in Files tab, plus add menu to alter priorities -* Implement add by url and add by hash +* Implement add by hash After 0.6 release: * Figure out easy way for user-made plugins to add i18n support. diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 1e83c456c..26a65fe67 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -168,6 +168,10 @@ class AddTorrentDialog: info = lt.torrent_info(filedump) + if str(info.info_hash()) in self.infos: + log.debug("Torrent already in list!") + return + # Get list of files from torrent info files = [] for f in info.files(): @@ -411,9 +415,16 @@ class AddTorrentDialog: # This is where we need to fetch the .torrent file from the URL and # add it to the list. log.debug("url: %s", url) + if url != None: + gobject.idle_add(self.download_from_url, url) + dialog.hide() - + def download_from_url(self, url): + import urllib + filename, headers = urllib.urlretrieve(url) + self.add_to_torrent_list([filename]) + def _on_button_hash_clicked(self, widget): log.debug("_on_button_hash_clicked") diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index 1f32542e0..a41ddfbd0 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -856,7 +856,6 @@ True 0 - True PANGO_WRAP_CHAR True