mirror of
https://github.com/mpv-player/mpv
synced 2025-01-30 11:42:04 +00:00
TOOLS/umpv: don't mangle URLs
This attempted to prefix the current directory to URLs, because it didn't recognize them as already absolute paths.
This commit is contained in:
parent
fa1b9517bc
commit
2a8f7181e3
17
TOOLS/umpv
17
TOOLS/umpv
@ -43,12 +43,27 @@ import errno
|
|||||||
import subprocess
|
import subprocess
|
||||||
import fcntl
|
import fcntl
|
||||||
import stat
|
import stat
|
||||||
|
import string
|
||||||
|
|
||||||
if len(sys.argv) < 1:
|
if len(sys.argv) < 1:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
files = sys.argv[1:]
|
files = sys.argv[1:]
|
||||||
|
|
||||||
|
# this is about the same method mpv uses to decide this
|
||||||
|
def is_url(filename):
|
||||||
|
parts = filename.split(":", 1)
|
||||||
|
if len(parts) < 2:
|
||||||
|
return False
|
||||||
|
# protocol prefix has no special characters => it's an URL
|
||||||
|
prefix = parts[0]
|
||||||
|
return len(prefix.translate(None, string.letters)) == 0
|
||||||
|
|
||||||
# make them absolute; also makes them safe against interpretation as options
|
# make them absolute; also makes them safe against interpretation as options
|
||||||
files = [os.path.abspath(f) for f in files]
|
def make_abs(filename):
|
||||||
|
if not is_url(filename):
|
||||||
|
return os.path.abspath(f)
|
||||||
|
return f
|
||||||
|
files = [make_abs(f) for f in files]
|
||||||
|
|
||||||
opts_env = os.getenv("UMPV_OPTIONS")
|
opts_env = os.getenv("UMPV_OPTIONS")
|
||||||
opts_env = opts_env.split() if opts_env else []
|
opts_env = opts_env.split() if opts_env else []
|
||||||
|
Loading…
Reference in New Issue
Block a user