1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

Added the ability to run a custom command

This commit is contained in:
mvpossum 2014-05-08 12:17:24 -03:00
parent 2bc33aeb2b
commit 380460503b

View File

@ -65,6 +65,7 @@ def main():
parser = argparse.ArgumentParser(description='Finds and downloads torrents from the Pirate Bay') parser = argparse.ArgumentParser(description='Finds and downloads torrents from the Pirate Bay')
parser.add_argument('q', metavar='search_term', help="The term to search for") parser.add_argument('q', metavar='search_term', help="The term to search for")
parser.add_argument('-t',dest='transmission',action='store_true', help="call transmission-remote to start the download", default=False) parser.add_argument('-t',dest='transmission',action='store_true', help="call transmission-remote to start the download", default=False)
parser.add_argument('--custom',dest='command', help="call custom command, %%s will be replaced with the url")
parser.add_argument('--local', dest='database', help="An xml file containing the Pirate Bay database") parser.add_argument('--local', dest='database', help="An xml file containing the Pirate Bay database")
parser.add_argument('-p', dest='pages', help="The number of pages to fetch (doesn't work with --local)", default=1) parser.add_argument('-p', dest='pages', help="The number of pages to fetch (doesn't work with --local)", default=1)
parser.add_argument('-0', dest='first', action='store_true', help="choose the top result", default=False) parser.add_argument('-0', dest='first', action='store_true', help="choose the top result", default=False)
@ -254,6 +255,8 @@ def main():
if args.transmission: if args.transmission:
os.system("""transmission-remote --add "%s" """ % (url)) os.system("""transmission-remote --add "%s" """ % (url))
os.system("transmission-remote -l") os.system("transmission-remote -l")
elif args.command:
os.system(args.custom % (url))
else: else:
webbrowser.open(url) webbrowser.open(url)