more macos
This commit is contained in:
1 parent
57afff3cf0
commit
ac29fda481
4 files changed
+15
-17
No files matched your search
+5
-3
@@ -3,13 +3,15 @@
|
|||||||
set -ue
|
set -ue
|
||||||
|
|
||||||
maple="$HOME/maple"
|
maple="$HOME/maple"
|
||||||
data="$HOME/maple/data"
|
|
||||||
metadata="$data/_metadata"
|
collection="$HOME/data/collection"
|
||||||
|
metadata="$collection/_metadata"
|
||||||
|
|
||||||
etc="$maple/etc"
|
etc="$maple/etc"
|
||||||
sldl_conf="$etc/sldl-macos.conf"
|
sldl_conf="$etc/sldl-macos.conf"
|
||||||
|
|
||||||
directories() {
|
directories() {
|
||||||
mkdir -p $data
|
mkdir -p $collection
|
||||||
mkdir -p $metadata
|
mkdir -p $metadata
|
||||||
mkdir -p $etc
|
mkdir -p $etc
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
path = "~/maple/data"
|
path = "~/maple/data/collection"
|
||||||
index-path = "~/maple/data/_metadata/index.sldl.csv"
|
index-path = "~/maple/data/_metadata/index.sldl.csv"
|
||||||
username = "ntwl"
|
username = "ntwl"
|
||||||
password = "ninety nonsense nights"
|
password = "ninety nonsense nights"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ dl trg:
|
|||||||
--remove-orphans \
|
--remove-orphans \
|
||||||
|
|
||||||
link plist dir:
|
link plist dir:
|
||||||
python3 maple-py/link.py plist dir
|
python3 maple-py/link.py {{plist}} {{dir}}
|
||||||
|
|
||||||
sync args:
|
sync args:
|
||||||
s5cmd {{args}}
|
s5cmd {{args}}
|
||||||
|
|||||||
+8
-12
@@ -3,20 +3,10 @@ import os, sys, pathlib
|
|||||||
|
|
||||||
m3u8 = pathlib.Path(sys.argv[1]).resolve()
|
m3u8 = pathlib.Path(sys.argv[1]).resolve()
|
||||||
outdir = pathlib.Path(sys.argv[2]).resolve()
|
outdir = pathlib.Path(sys.argv[2]).resolve()
|
||||||
|
print(outdir)
|
||||||
outdir.mkdir(parents=True, exist_ok=True)
|
outdir.mkdir(parents=True, exist_ok=True)
|
||||||
pl_dir = m3u8.parent
|
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:
|
with m3u8.open("r", encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
s = line.strip()
|
s = line.strip()
|
||||||
@@ -32,8 +22,14 @@ with m3u8.open("r", encoding="utf-8") as f:
|
|||||||
print(f"skip (missing): {src}", file=sys.stderr)
|
print(f"skip (missing): {src}", file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
dest = next_free(outdir / src.name)
|
dest = outdir / src.name
|
||||||
|
|
||||||
|
if dest.exists():
|
||||||
|
print(f"skip (exists): {dest}", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
print(f"{src} -> {dest}")
|
||||||
dest.symlink_to(src)
|
dest.symlink_to(src)
|
||||||
except OSError:
|
except OSError:
|
||||||
# fallback to hardlink if symlink not permitted
|
# fallback to hardlink if symlink not permitted
|
||||||
|
|||||||
Reference in new issue
Block a user