Skip to content

Commit

Permalink
Version 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kz26 committed Sep 2, 2016
1 parent 7c0719f commit adf48a7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
21 changes: 11 additions & 10 deletions bin/dottorrent_cli
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ if __name__ == '__main__':
parser.add_argument(
'path', help='path to file/directory to create torrent from')
parser.add_argument(
'output_file', help='Output filename for created .torrent file')
'output_path', help='Output path for created .torrent file. \
If a directory is provided, the filename will be automatically \
generated based on the input.')
args = parser.parse_args()

if args.date:
Expand Down Expand Up @@ -112,16 +114,15 @@ if __name__ == '__main__':

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

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))

output_path = os.path.normpath(args.output_path)
if os.path.isdir(output_path):
path_base = os.path.splitext(os.path.basename(t.path))[0]
save_fn = os.path.join(args.output_path, path_base + '.torrent')
else:
save_name = args.output_path
save_fn = args.output_path

with open(save_name, 'wb') as f:
with open(save_fn, 'wb') as f:
t.save(f)
print("Info hash: " + t.info_hash)
print("Torrent file saved to {}".format(args.output_file))
print("Torrent file saved to {}".format(save_fn))
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.5.0
-----
* Allow both file and directory names to be specified for output_path (PR #1, @mahkitah)

1.4.3
-----
* dottorrent_cli: Change output_path to output_file for clarity
Expand Down
9 changes: 6 additions & 3 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ available in your system path.
usage: dottorrent_cli [-h] [--tracker TRACKER] [--web_seed WEB_SEED]
[--piece_size PIECE_SIZE] [--private]
[--comment COMMENT] [--date DATE] [--md5] [--verbose]
path output_file
path output_path

Create a .torrent file

positional arguments:
path path to file/directory to create torrent from
output_file Output filename for created .torrent file
output_path Output path for created .torrent file. If a directory
is provided, the filename will be automatically
generated based on the input.

optional arguments:
-h, --help show this help message and exit
Expand All @@ -35,7 +37,8 @@ available in your system path.
--md5 Add per-file MD5 hashes
--verbose, -v verbose mode

dottorrent/1.4.3 (https://github.com/kz26/dottorrent)
dottorrent/1.5.0 (https://github.com/kz26/dottorrent)



To add multiple trackers and/or web seeds, repeat the ``-t`` and ``-w`` as many times as necessary,
Expand Down
2 changes: 1 addition & 1 deletion dottorrent/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.3'
__version__ = '1.5.0'

0 comments on commit adf48a7

Please sign in to comment.