Skip to content

Commit

Permalink
Merge pull request #1 from mahkitah/patch-1
Browse files Browse the repository at this point in the history
allow file and folder as output path
  • Loading branch information
kz26 committed Sep 1, 2016
2 parents 3c0b588 + 65538b4 commit 7c0719f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bin/dottorrent_cli
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# SOFTWARE.

import argparse
import os.path
from datetime import datetime

from humanfriendly import format_size
Expand Down Expand Up @@ -111,8 +112,16 @@ if __name__ == '__main__':

t.generate(callback=progress_callback)
pbar.close()

with open(args.output_file, 'wb') as f:

if os.path.isdir(args.output_path):
last_part = os.path.basename(args.path)
no_ext = os.path.splitext(last_part)[0]

save_name = os.path.join(args.output_path, '{}.torrent'.format(no_ext))
else:
save_name = args.output_path

with open(save_name, 'wb') as f:
t.save(f)
print("Info hash: " + t.info_hash)
print("Torrent file saved to {}".format(args.output_file))

0 comments on commit 7c0719f

Please sign in to comment.