def run(self):
def callback(*args):
return self.isInterruptionRequested()
entries = os.listdir(self.path)
for i, p in enumerate(entries):
if any(fnmatch(p, ex) for ex in self.exclude):
continue
p = os.path.join(self.path, p)
if not dottorrent.is_hidden_file(p):
sfn = os.path.split(p)[1] + '.torrent'
self.progress_update.emit(sfn, i, len(entries))
t = dottorrent.Torrent(
p,
exclude=self.exclude,
trackers=self.trackers,
web_seeds=self.web_seeds,
private=self.private,
source=self.source,
comment=self.comment,
include_md5=self.include_md5,
creation_date=datetime.now(),
created_by=CREATOR
)
try:
self.success = t.generate(callback=callback)
# ignore empty inputs
except dottorrent.exceptions.EmptyInputException:
continue
except Exception as exc:
self.onError.emit(str(exc))
return
if self.isInterruptionRequested():
return
if self.success:
with open(os.path.join(self.save_dir, sfn), 'wb') as f:
t.save(f)
评论列表
文章目录