1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-09 09:59:51 +01:00

fix command execution vlun when using -C or openCommand, close #46

This commit is contained in:
Viktor Stanchev 2015-04-15 15:41:02 -04:00
parent 86f5a1277d
commit b55e619441

View File

@ -113,6 +113,13 @@ class NoRedirection(request.HTTPErrorProcessor):
https_response = http_response
cmd_args_regex = '''(('[^']*'|"[^"]*"|(\\\\\\s|[^\\s])+)+ *)'''
def parse_cmd(cmd, url):
ret = re.findall(cmd_args_regex, cmd)
ret2 = list(map(lambda x: x[0].strip(), ret))
ret3 = list(map(lambda x: x.replace('%s', url), ret2))
return ret3
# create a subclass and override the handler methods
class BayParser(HTMLParser):
title = ''
@ -489,7 +496,6 @@ def main():
action='store_true',
help='open magnets with transmission-remote')
parser.add_argument('-C', '--custom', dest='command',
action='store_true',
help='open magnets with a custom command'
' (%%s will be replaced with the url)')
parser.add_argument('-M', '--save-magnets',
@ -675,7 +681,7 @@ def main():
command = config.get('Misc', 'openCommand')
if args.command:
command = args.command
os.system(command % url)
subprocess.call(parse_cmd(command, url), shell=False)
else:
webbrowser.open(url)