mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-24 18:29:12 +00:00
Torrent creation fixes in regards to web seeds
Fix adding torrent to session after creation by setting the proper download location
This commit is contained in:
parent
95cd5e4932
commit
ff25a7e969
@ -616,7 +616,7 @@ class Core(component.Component):
|
||||
|
||||
@export
|
||||
def create_torrent(self, path, tracker, piece_length, comment, target,
|
||||
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||
webseeds, private, created_by, trackers, add_to_session):
|
||||
|
||||
log.debug("creating torrent..")
|
||||
threading.Thread(target=_create_torrent_thread,
|
||||
@ -626,15 +626,14 @@ class Core(component.Component):
|
||||
piece_length,
|
||||
comment,
|
||||
target,
|
||||
url_list,
|
||||
webseeds,
|
||||
private,
|
||||
created_by,
|
||||
httpseeds,
|
||||
trackers,
|
||||
add_to_session)).start()
|
||||
|
||||
def _create_torrent_thread(self, path, tracker, piece_length, comment, target,
|
||||
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||
webseeds, private, created_by, trackers, add_to_session):
|
||||
import deluge.metafile
|
||||
deluge.metafile.make_meta_file(
|
||||
path,
|
||||
@ -642,10 +641,9 @@ class Core(component.Component):
|
||||
piece_length,
|
||||
comment=comment,
|
||||
target=target,
|
||||
url_list=url_list,
|
||||
webseeds=webseeds,
|
||||
private=private,
|
||||
created_by=created_by,
|
||||
httpseeds=httpseeds,
|
||||
trackers=trackers)
|
||||
log.debug("torrent created!")
|
||||
if add_to_session:
|
||||
|
@ -57,8 +57,8 @@ def dummy(v):
|
||||
|
||||
def make_meta_file(path, url, piece_length, progress=dummy,
|
||||
title=None, comment=None, safe=None, content_type=None,
|
||||
target=None, url_list=None, name=None, private=False,
|
||||
created_by=None, httpseeds=None, trackers=None):
|
||||
target=None, webseeds=None, name=None, private=False,
|
||||
created_by=None, trackers=None):
|
||||
data = {'creation date': int(gmtime())}
|
||||
if url:
|
||||
data['announce'] = url.strip()
|
||||
@ -77,20 +77,34 @@ def make_meta_file(path, url, piece_length, progress=dummy,
|
||||
|
||||
data['info'] = info
|
||||
if title:
|
||||
data['title'] = title
|
||||
data['title'] = title.encode("utf8")
|
||||
if comment:
|
||||
data['comment'] = comment
|
||||
data['comment'] = comment.encode("utf8")
|
||||
if safe:
|
||||
data['safe'] = safe
|
||||
data['safe'] = safe.encode("utf8")
|
||||
|
||||
httpseeds = []
|
||||
url_list = []
|
||||
|
||||
if webseeds:
|
||||
for webseed in webseeds:
|
||||
if webseed.endswith(".php"):
|
||||
httpseeds.append(webseed)
|
||||
else:
|
||||
url_list.append(webseed)
|
||||
|
||||
if url_list:
|
||||
data['url-list'] = url_list
|
||||
if created_by:
|
||||
data['created by'] = created_by
|
||||
if httpseeds:
|
||||
data['httpseeds'] = httpseeds
|
||||
if created_by:
|
||||
data['created by'] = created_by.encode("utf8")
|
||||
|
||||
if trackers:
|
||||
data['announce-list'] = trackers
|
||||
|
||||
data["encoding"] = "UTF-8"
|
||||
|
||||
h.write(bencode(data))
|
||||
h.close()
|
||||
|
||||
|
@ -258,11 +258,22 @@ class CreateTorrentDialog:
|
||||
# Get the path
|
||||
path = self.files_treestore[0][0]
|
||||
# Get a list of trackers
|
||||
trackers = [t[1] for t in self.trackers_liststore]
|
||||
if len(trackers) == 0:
|
||||
trackers = []
|
||||
if not len(self.trackers_liststore):
|
||||
tracker = None
|
||||
else:
|
||||
tracker = trackers[0]
|
||||
# Create a list of lists [[tier0, ...], [tier1, ...], ...]
|
||||
for tier, tracker in self.trackers_liststore:
|
||||
try:
|
||||
tier_list = trackers[tier]
|
||||
except IndexError:
|
||||
trackers.insert(tier, [])
|
||||
|
||||
trackers[tier].append(tracker)
|
||||
|
||||
# Get the first tracker in the first tier
|
||||
tracker = trackers[0][0]
|
||||
|
||||
# Get a list of webseeds
|
||||
webseeds = []
|
||||
b = self.glade.get_widget("textview_webseeds").get_buffer()
|
||||
@ -288,10 +299,9 @@ class CreateTorrentDialog:
|
||||
piece_length,
|
||||
comment,
|
||||
result,
|
||||
None,
|
||||
webseeds,
|
||||
private,
|
||||
author,
|
||||
webseeds,
|
||||
trackers,
|
||||
add_to_session)
|
||||
|
||||
@ -309,10 +319,9 @@ class CreateTorrentDialog:
|
||||
self._on_create_torrent_progress,
|
||||
comment,
|
||||
result,
|
||||
trackers,
|
||||
webseeds,
|
||||
private,
|
||||
author,
|
||||
webseeds,
|
||||
trackers,
|
||||
add_to_session)).start()
|
||||
|
||||
@ -320,7 +329,7 @@ class CreateTorrentDialog:
|
||||
self.dialog.destroy()
|
||||
|
||||
def create_torrent(self, path, tracker, piece_length, progress, comment, target,
|
||||
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||
webseeds, private, created_by, trackers, add_to_session):
|
||||
import deluge.metafile
|
||||
deluge.metafile.make_meta_file(
|
||||
path,
|
||||
@ -329,17 +338,16 @@ class CreateTorrentDialog:
|
||||
progress=progress,
|
||||
comment=comment,
|
||||
target=target,
|
||||
url_list=url_list,
|
||||
webseeds=webseeds,
|
||||
private=private,
|
||||
created_by=created_by,
|
||||
httpseeds=httpseeds,
|
||||
trackers=trackers)
|
||||
self.glade.get_widget("progress_dialog").hide_all()
|
||||
if add_to_session:
|
||||
client.core.add_torrent_file(
|
||||
os.path.split(target)[-1],
|
||||
base64.encodestring(open(target).read()),
|
||||
None)
|
||||
{"download_location": os.path.split(path)[0]})
|
||||
|
||||
def _on_create_torrent_progress(self, value, num_pieces):
|
||||
percent = float(value)/float(num_pieces)
|
||||
|
Loading…
x
Reference in New Issue
Block a user