more macos
This commit is contained in:
1 parent
57afff3cf0
commit
ac29fda481
4 files changed
+15
-17
No files matched your search
+8
-12
@@ -3,20 +3,10 @@ import os, sys, pathlib
|
||||
|
||||
m3u8 = pathlib.Path(sys.argv[1]).resolve()
|
||||
outdir = pathlib.Path(sys.argv[2]).resolve()
|
||||
print(outdir)
|
||||
outdir.mkdir(parents=True, exist_ok=True)
|
||||
pl_dir = m3u8.parent
|
||||
|
||||
def next_free(p: pathlib.Path) -> pathlib.Path:
|
||||
if not p.exists():
|
||||
return p
|
||||
stem, suf = p.stem, p.suffix
|
||||
i = 1
|
||||
while True:
|
||||
cand = p.with_name(f"{stem}-{i}{suf}")
|
||||
if not cand.exists():
|
||||
return cand
|
||||
i += 1
|
||||
|
||||
with m3u8.open("r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
s = line.strip()
|
||||
@@ -32,8 +22,14 @@ with m3u8.open("r", encoding="utf-8") as f:
|
||||
print(f"skip (missing): {src}", file=sys.stderr)
|
||||
continue
|
||||
|
||||
dest = next_free(outdir / src.name)
|
||||
dest = outdir / src.name
|
||||
|
||||
if dest.exists():
|
||||
print(f"skip (exists): {dest}", file=sys.stderr)
|
||||
continue
|
||||
|
||||
try:
|
||||
print(f"{src} -> {dest}")
|
||||
dest.symlink_to(src)
|
||||
except OSError:
|
||||
# fallback to hardlink if symlink not permitted
|
||||
|
||||
Reference in new issue
Block a user