mirror of
https://github.com/mpv-player/mpv
synced 2025-03-06 22:28:01 +00:00
TOOLS/umpv: make URL detection consistent with mpv method
See mp_is_url in options/path.c.
This commit is contained in:
parent
dfbb4d03ee
commit
bb005a385a
10
TOOLS/umpv
10
TOOLS/umpv
@ -50,17 +50,15 @@ 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
|
# this is the same method mpv uses to decide this
|
||||||
def is_url(filename):
|
def is_url(filename):
|
||||||
parts = filename.split(":", 1)
|
parts = filename.split("://", 1)
|
||||||
if len(parts) < 2:
|
if len(parts) < 2:
|
||||||
return False
|
return False
|
||||||
# protocol prefix has no special characters => it's an URL
|
# protocol prefix has no special characters => it's an URL
|
||||||
|
allowed_symbols = string.ascii_letters + string.digits + '_'
|
||||||
prefix = parts[0]
|
prefix = parts[0]
|
||||||
for c in prefix:
|
return all(map(lambda c: c in allowed_symbols, prefix))
|
||||||
if string.ascii_letters.find(c) < 0:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
# make them absolute; also makes them safe against interpretation as options
|
# make them absolute; also makes them safe against interpretation as options
|
||||||
def make_abs(filename):
|
def make_abs(filename):
|
||||||
|
Loading…
Reference in New Issue
Block a user