playlist-admin 2.15.17 → 2.15.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -99
- package/cli/index.js +128 -128
- package/package.json +34 -34
- package/rag/README.md +47 -47
- package/rag/_resolve.py +65 -65
- package/rag/build_db.py +301 -301
- package/rag/query.py +216 -216
- package/rag/srt_to_text.py +49 -49
package/rag/_resolve.py
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
"""Resolve podcast RAG paths from the app config (same as the CLI/GUI)."""
|
|
2
|
-
import json
|
|
3
|
-
import os
|
|
4
|
-
import platform
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def _is_wsl() -> bool:
|
|
9
|
-
"""偵測是否在 WSL 中執行。"""
|
|
10
|
-
if "microsoft" in platform.release().lower():
|
|
11
|
-
return True
|
|
12
|
-
if os.path.exists("/proc/sys/fs/binfmt_misc/WSLInterop"):
|
|
13
|
-
return True
|
|
14
|
-
return False
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def _win_to_wsl(path: Path) -> Path:
|
|
18
|
-
"""將 Windows 路徑轉為 WSL /mnt/c/... 路徑。"""
|
|
19
|
-
s = str(path)
|
|
20
|
-
if len(s) >= 2 and s[1] == ":":
|
|
21
|
-
drive = s[0].lower()
|
|
22
|
-
rest = s[2:].replace("\\", "/")
|
|
23
|
-
return Path(f"/mnt/{drive}{rest}")
|
|
24
|
-
return path
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def find_base() -> Path:
|
|
28
|
-
env_bp = os.environ.get("BASE_PATH")
|
|
29
|
-
if env_bp:
|
|
30
|
-
bp = Path(env_bp)
|
|
31
|
-
if _is_wsl():
|
|
32
|
-
bp = _win_to_wsl(bp)
|
|
33
|
-
return bp
|
|
34
|
-
|
|
35
|
-
# WSL: 直接用 /mnt/c/ 路徑
|
|
36
|
-
if _is_wsl():
|
|
37
|
-
return Path("/mnt/c/Users/CPXru/Music/playlist-admin")
|
|
38
|
-
|
|
39
|
-
# Windows: 讀 config.json
|
|
40
|
-
local = os.environ.get("LOCALAPPDATA")
|
|
41
|
-
pointer = None
|
|
42
|
-
if local:
|
|
43
|
-
pointer = Path(local) / "playlist-admin" / "data" / "config.json"
|
|
44
|
-
if not pointer.exists():
|
|
45
|
-
pointer = Path(local) / "Playlist Administrator" / "data" / "config.json"
|
|
46
|
-
try:
|
|
47
|
-
if pointer and pointer.exists():
|
|
48
|
-
data = json.loads(pointer.read_text(encoding="utf-8"))
|
|
49
|
-
bp = data.get("base_path") or data.get("basePath")
|
|
50
|
-
if bp:
|
|
51
|
-
return Path(bp)
|
|
52
|
-
except Exception:
|
|
53
|
-
pass
|
|
54
|
-
return Path(r"C:\Users\CPXru\Music\playlist-admin")
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def podcast_downloads_dir() -> Path:
|
|
58
|
-
return find_base() / "podcasts"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def rag_data_dir() -> Path:
|
|
62
|
-
return find_base() / "cache" / "podcast"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def chroma_db_dir() -> Path:
|
|
1
|
+
"""Resolve podcast RAG paths from the app config (same as the CLI/GUI)."""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import platform
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _is_wsl() -> bool:
|
|
9
|
+
"""偵測是否在 WSL 中執行。"""
|
|
10
|
+
if "microsoft" in platform.release().lower():
|
|
11
|
+
return True
|
|
12
|
+
if os.path.exists("/proc/sys/fs/binfmt_misc/WSLInterop"):
|
|
13
|
+
return True
|
|
14
|
+
return False
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _win_to_wsl(path: Path) -> Path:
|
|
18
|
+
"""將 Windows 路徑轉為 WSL /mnt/c/... 路徑。"""
|
|
19
|
+
s = str(path)
|
|
20
|
+
if len(s) >= 2 and s[1] == ":":
|
|
21
|
+
drive = s[0].lower()
|
|
22
|
+
rest = s[2:].replace("\\", "/")
|
|
23
|
+
return Path(f"/mnt/{drive}{rest}")
|
|
24
|
+
return path
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def find_base() -> Path:
|
|
28
|
+
env_bp = os.environ.get("BASE_PATH")
|
|
29
|
+
if env_bp:
|
|
30
|
+
bp = Path(env_bp)
|
|
31
|
+
if _is_wsl():
|
|
32
|
+
bp = _win_to_wsl(bp)
|
|
33
|
+
return bp
|
|
34
|
+
|
|
35
|
+
# WSL: 直接用 /mnt/c/ 路徑
|
|
36
|
+
if _is_wsl():
|
|
37
|
+
return Path("/mnt/c/Users/CPXru/Music/playlist-admin")
|
|
38
|
+
|
|
39
|
+
# Windows: 讀 config.json
|
|
40
|
+
local = os.environ.get("LOCALAPPDATA")
|
|
41
|
+
pointer = None
|
|
42
|
+
if local:
|
|
43
|
+
pointer = Path(local) / "playlist-admin" / "data" / "config.json"
|
|
44
|
+
if not pointer.exists():
|
|
45
|
+
pointer = Path(local) / "Playlist Administrator" / "data" / "config.json"
|
|
46
|
+
try:
|
|
47
|
+
if pointer and pointer.exists():
|
|
48
|
+
data = json.loads(pointer.read_text(encoding="utf-8"))
|
|
49
|
+
bp = data.get("base_path") or data.get("basePath")
|
|
50
|
+
if bp:
|
|
51
|
+
return Path(bp)
|
|
52
|
+
except Exception:
|
|
53
|
+
pass
|
|
54
|
+
return Path(r"C:\Users\CPXru\Music\playlist-admin")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def podcast_downloads_dir() -> Path:
|
|
58
|
+
return find_base() / "podcasts"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def rag_data_dir() -> Path:
|
|
62
|
+
return find_base() / "cache" / "podcast"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def chroma_db_dir() -> Path:
|
|
66
66
|
return rag_data_dir() / "chroma_db"
|