mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
fix command execution vlun when using -C or openCommand, close #46
This commit is contained in:
parent
86f5a1277d
commit
b55e619441
@ -113,6 +113,13 @@ class NoRedirection(request.HTTPErrorProcessor):
|
|||||||
https_response = http_response
|
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
|
# create a subclass and override the handler methods
|
||||||
class BayParser(HTMLParser):
|
class BayParser(HTMLParser):
|
||||||
title = ''
|
title = ''
|
||||||
@ -489,7 +496,6 @@ def main():
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='open magnets with transmission-remote')
|
help='open magnets with transmission-remote')
|
||||||
parser.add_argument('-C', '--custom', dest='command',
|
parser.add_argument('-C', '--custom', dest='command',
|
||||||
action='store_true',
|
|
||||||
help='open magnets with a custom command'
|
help='open magnets with a custom command'
|
||||||
' (%%s will be replaced with the url)')
|
' (%%s will be replaced with the url)')
|
||||||
parser.add_argument('-M', '--save-magnets',
|
parser.add_argument('-M', '--save-magnets',
|
||||||
@ -675,7 +681,7 @@ def main():
|
|||||||
command = config.get('Misc', 'openCommand')
|
command = config.get('Misc', 'openCommand')
|
||||||
if args.command:
|
if args.command:
|
||||||
command = args.command
|
command = args.command
|
||||||
os.system(command % url)
|
subprocess.call(parse_cmd(command, url), shell=False)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user