add web seeds to torrent creator

This commit is contained in:
Marcos Pinto 2007-12-02 22:36:02 +00:00
parent 4f55d7dfc6
commit 856420c640
4 changed files with 132 additions and 63 deletions

View File

@ -133,6 +133,10 @@ class TorrentCreator:
trackers = self.glade.get_widget("trackers_textview").get_buffer()
(start, end) = trackers.get_bounds()
trackers = trackers.get_text(start, end).strip()
webseeds = self.glade.get_widget("webseeds_textview").get_buffer()
(start, end) = webseeds.get_bounds()
webseeds = webseeds.get_text(start, end).strip()
comments = self.glade.get_widget("comments_textview").get_buffer()
(start, end) = comments.get_bounds()
@ -150,7 +154,7 @@ class TorrentCreator:
# Create the torrent and add it to the queue if necessary
if self.core.create_torrent(torrent, source, trackers, comments,
piece_size, author, set_private) == 1:
piece_size, author, set_private, webseeds) == 1:
# Torrent was created successfully
if add_torrent:
# We need to add this torrent to the queue

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Thu Oct 25 22:18:52 2007 by markybob@peg-->
<!--Generated with glade3 3.4.0 on Sun Dec 2 16:02:19 2007 -->
<glade-interface>
<widget class="GtkDialog" id="torrentcreator">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -54,6 +54,7 @@
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment2">
@ -69,28 +70,17 @@
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkFileChooserButton" id="file_chooserbutton">
<widget class="GtkRadioButton" id="folder_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">This torrent will be made from a directory</property>
<property name="label" translatable="yes">Folder:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="folder_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
@ -112,17 +102,28 @@
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="folder_radiobutton">
<widget class="GtkFileChooserButton" id="folder_chooserbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">This torrent will be made from a directory</property>
<property name="label" translatable="yes">Folder:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="file_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
@ -150,6 +151,7 @@
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment3">
@ -169,22 +171,14 @@
<property name="n_rows">1</property>
<property name="n_columns">3</property>
<child>
<widget class="GtkAlignment" id="alignment8">
<widget class="GtkEntry" id="torrentfile_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Save Torrent File As:</property>
</widget>
</child>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
@ -212,14 +206,22 @@
</packing>
</child>
<child>
<widget class="GtkEntry" id="torrentfile_entry">
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Save Torrent File As:</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
@ -269,6 +271,7 @@
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment4">
@ -311,10 +314,58 @@
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkViewport" id="viewport5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="resize_mode">GTK_RESIZE_QUEUE</property>
<child>
<widget class="GtkTextView" id="webseeds_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="wrap_mode">GTK_WRAP_CHAR</property>
<property name="accepts_tab">False</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Web Seeds&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment5">
@ -354,13 +405,14 @@
</child>
</widget>
<packing>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment6">
@ -391,7 +443,7 @@
</widget>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -416,17 +468,15 @@
<placeholder/>
</child>
<child>
<widget class="GtkCheckButton" id="chk_set_priv">
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Set Private Flag</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<property name="tooltip" translatable="yes">The smaller the piece sizes, the more efficient the transfers will be, but the actual ".torrent" file will be larger</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Piece Size:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
@ -451,15 +501,17 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<widget class="GtkCheckButton" id="chk_set_priv">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">The smaller the piece sizes, the more efficient the transfers will be, but the actual ".torrent" file will be larger</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Piece Size:</property>
<property name="label" translatable="yes">Set Private Flag</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="y_options"></property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
@ -481,7 +533,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
</widget>

View File

@ -1015,8 +1015,8 @@ Space:") + " " + nice_free)
return ret
def create_torrent(self, filename, source_directory, trackers, comments=None,
piece_size=32, author="Deluge", private=False):
return deluge_core.create_torrent(filename, source_directory, trackers, comments, piece_size, author, private)
piece_size=32, author="Deluge", private=False, webseeds=None):
return deluge_core.create_torrent(filename, source_directory, trackers, comments, piece_size, author, private, webseeds)
# Creates/resets the IP filter list
def reset_ip_filter(self):

View File

@ -1547,11 +1547,11 @@ static PyObject *torrent_create_torrent(PyObject *self, PyObject *args)
//path::default_name_check(no_check);
char *destination, *comment, *creator_str, *input, *trackers;
char *destination, *comment, *creator_str, *input, *trackers, *webseeds;
bool *priv;
python_long piece_size;
if (!PyArg_ParseTuple(args, "ssssisb",
&destination, &input, &trackers, &comment, &piece_size, &creator_str, &priv))
if (!PyArg_ParseTuple(args, "ssssisbs",
&destination, &input, &trackers, &comment, &piece_size, &creator_str, &priv, &webseeds))
return NULL;
piece_size = piece_size * 1024;
@ -1582,6 +1582,19 @@ static PyObject *torrent_create_torrent(PyObject *self, PyObject *args)
break;
}
std::string stdWebseeds(webseeds);
unsigned long index2 = 0, next2 = stdWebseeds.find("\n");
while (1 == 1)
{
t->add_url_seed(stdWebseeds.substr(index2, next2-index));
index2 = next2 + 1;
if (next2 >= stdWebseeds.length())
break;
next2 = stdWebseeds.find("\n", index2);
if (next2 == std::string::npos)
break;
}
int num = t->num_pieces();
std::vector<char> buf(piece_size);
for (int i = 0; i < num; ++i)