From b16fe00f138782aa7f92586157936e380478b2fc Mon Sep 17 00:00:00 2001 From: Nemo Date: Wed, 26 Jan 2022 21:08:53 +0530 Subject: [PATCH] fix create torrent script --- create-new-torrent | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/create-new-torrent b/create-new-torrent index 86d7e4e..1208a9b 100755 --- a/create-new-torrent +++ b/create-new-torrent @@ -20,18 +20,23 @@ Most common options you might want to overwrite are arguments = sys.argv del arguments[0] +if len(sys.argv) < 1: + print("Invalid arguments") + print(" create-new-torrent --output file.torrent /path/to/directory") + sys.exit(1) + # Last argument must be the directory or file directory = sys.argv[-1] comment = None # Only try for a comment if we have a directory -if os.path.isdir(directory) +if os.path.isdir(directory): for file in ["README.txt", "readme.txt", "README.md", "readme.md", "README.nfo"]: file_path = directory + "/" + file if os.path.exists(file_path): with open(file_path, 'r') as f: comment = f.read() - if !comment + if not comment: print("Could not find a readme file in %s" % directory) # Add all trackers