Index: action.py ================================================================== --- action.py +++ action.py @@ -2,11 +2,11 @@ # api: streamtuner2 # type: functions # category: io # title: play/record actions # description: Starts audio applications, guesses MIME types for URLs -# version: 1.1.2 +# version: 1.2.0 # priority: core # # Multimedia interface for starting audio players, recording app, # or web browser (listed as "url/http" association in players). # It maps audio MIME types, and extracts/converts playlist types @@ -35,10 +35,11 @@ import re import os import platform import copy import json +import subprocess, pipes from datetime import datetime from xml.sax.saxutils import escape as xmlentities, unescape as xmlunescape import ahttp from config import * @@ -130,11 +131,13 @@ # Exec wrapper def run(cmd): - if conf.windows: + if "exec" in conf: + cmd = conf.cmd % cmd + elif conf.windows: cmd = "start " + cmd else: cmd = cmd + " &" try: log.EXEC(cmd) @@ -177,18 +180,20 @@ # OS shell command escaping # def quote(ins): - if conf.windows: - Q = '"%s%"' - else: - Q = "%r" - if type(ins) is list: - return " ".join([Q % str(s) for s in ins]) - else: - return Q % str(ins) + if type(ins) is list: + return " ".join([quote(s) for s in ins]) + # Windows: double quotes + elif conf.windows: + return subprocess.list2cmdline([ins]) + return '"%s"' % ins + # Posix-style shell quoting + else: + return pipes.quote(ins) + return "%r" % ins # Convert e.g. "text/x-scpls" MIME types to just "pls" monikers # def listfmt(t = "pls"):