diff --git a/etc/maple_setup.sh b/etc/maple_setup.sh index b42e3e5..74c0568 100755 --- a/etc/maple_setup.sh +++ b/etc/maple_setup.sh @@ -3,13 +3,15 @@ set -ue maple="$HOME/maple" -data="$HOME/maple/data" -metadata="$data/_metadata" + +collection="$HOME/data/collection" +metadata="$collection/_metadata" + etc="$maple/etc" sldl_conf="$etc/sldl-macos.conf" directories() { - mkdir -p $data + mkdir -p $collection mkdir -p $metadata mkdir -p $etc } diff --git a/etc/sldl.macos.yaml b/etc/sldl.macos.yaml index 8e3cd58..a9668bc 100644 --- a/etc/sldl.macos.yaml +++ b/etc/sldl.macos.yaml @@ -1,4 +1,4 @@ -path = "~/maple/data" +path = "~/maple/data/collection" index-path = "~/maple/data/_metadata/index.sldl.csv" username = "ntwl" password = "ninety nonsense nights" diff --git a/justfile b/justfile index d66ad9e..e5e1bfe 100644 --- a/justfile +++ b/justfile @@ -26,7 +26,7 @@ dl trg: --remove-orphans \ link plist dir: - python3 maple-py/link.py plist dir + python3 maple-py/link.py {{plist}} {{dir}} sync args: s5cmd {{args}} diff --git a/maple-py/link.py b/maple-py/link.py index 90e7cf4..0c2d8cd 100644 --- a/maple-py/link.py +++ b/maple-py/link.py @@ -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