@jakende/media-info-cli 0.1.1 → 0.1.3
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 +10 -1
- package/bin/media-information-download.js +53 -1
- package/media_information_download/config.py +5 -0
- package/package.json +1 -1
- package/pyproject.toml +1 -1
package/README.md
CHANGED
|
@@ -88,10 +88,19 @@ npm install -g @jakende/media-info-cli
|
|
|
88
88
|
media-info-cli
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
On first run, the npm wrapper creates a Python virtual environment in `~/.media-information-download/venv` and installs the Python dependencies there.
|
|
91
|
+
On first run, the npm wrapper creates a Python virtual environment in `~/.media-information-download/venv` and installs the Python dependencies there. Npm installs write generated media and transcripts to `~/.media-information-download/output` by default.
|
|
92
|
+
|
|
93
|
+
To create a Desktop alias/shortcut to the output folder:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
media-info-cli --desktop-output-alias
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
To use a different venv or output location:
|
|
92
100
|
|
|
93
101
|
```bash
|
|
94
102
|
MEDIA_INFORMATION_DOWNLOAD_VENV=/path/to/venv media-information-download
|
|
103
|
+
MEDIA_OUTPUT_DIR=/path/to/output media-information-download
|
|
95
104
|
```
|
|
96
105
|
|
|
97
106
|
## TUI
|
|
@@ -10,10 +10,14 @@ const packageRoot = path.resolve(__dirname, "..");
|
|
|
10
10
|
const venvRoot = process.env.MEDIA_INFORMATION_DOWNLOAD_VENV
|
|
11
11
|
? path.resolve(process.env.MEDIA_INFORMATION_DOWNLOAD_VENV)
|
|
12
12
|
: path.join(os.homedir(), ".media-information-download", "venv");
|
|
13
|
+
const outputRoot = process.env.MEDIA_OUTPUT_DIR
|
|
14
|
+
? path.resolve(process.env.MEDIA_OUTPUT_DIR)
|
|
15
|
+
: path.join(os.homedir(), ".media-information-download", "output");
|
|
13
16
|
const isWindows = process.platform === "win32";
|
|
14
17
|
const venvPython = isWindows
|
|
15
18
|
? path.join(venvRoot, "Scripts", "python.exe")
|
|
16
19
|
: path.join(venvRoot, "bin", "python");
|
|
20
|
+
const desktopAliasArgs = new Set(["--desktop-output-alias", "--create-desktop-output-alias"]);
|
|
17
21
|
|
|
18
22
|
function run(command, args, options = {}) {
|
|
19
23
|
const result = spawnSync(command, args, {
|
|
@@ -21,6 +25,8 @@ function run(command, args, options = {}) {
|
|
|
21
25
|
stdio: options.stdio || "inherit",
|
|
22
26
|
env: {
|
|
23
27
|
...process.env,
|
|
28
|
+
MEDIA_OUTPUT_DIR: outputRoot,
|
|
29
|
+
MEDIA_INFORMATION_DOWNLOAD_VENV: venvRoot,
|
|
24
30
|
PYTHONPATH: packageRoot,
|
|
25
31
|
},
|
|
26
32
|
});
|
|
@@ -91,11 +97,57 @@ function warnIfFfmpegMissing() {
|
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
|
|
100
|
+
function splitWrapperArgs(args) {
|
|
101
|
+
return {
|
|
102
|
+
createDesktopOutputAlias: args.some((arg) => desktopAliasArgs.has(arg)),
|
|
103
|
+
appArgs: args.filter((arg) => !desktopAliasArgs.has(arg)),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function pathToFileUrl(value) {
|
|
108
|
+
return `file:///${value.replace(/\\/g, "/").replace(/^\/+/, "")}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function createDesktopOutputAlias() {
|
|
112
|
+
const desktopPath = path.join(os.homedir(), "Desktop");
|
|
113
|
+
const aliasName = "Media Information Download Output";
|
|
114
|
+
const aliasPath = path.join(desktopPath, aliasName);
|
|
115
|
+
|
|
116
|
+
fs.mkdirSync(outputRoot, { recursive: true });
|
|
117
|
+
fs.mkdirSync(desktopPath, { recursive: true });
|
|
118
|
+
if (fs.existsSync(aliasPath)) {
|
|
119
|
+
console.log(`Output alias already exists: ${aliasPath}`);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (isWindows) {
|
|
124
|
+
const command = `mklink /J "${aliasPath}" "${outputRoot}"`;
|
|
125
|
+
const result = spawnSync("cmd", ["/d", "/s", "/c", command], { stdio: "ignore" });
|
|
126
|
+
if (result.status === 0) {
|
|
127
|
+
console.log(`Created output alias: ${aliasPath}`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const shortcutPath = `${aliasPath}.url`;
|
|
132
|
+
fs.writeFileSync(shortcutPath, `[InternetShortcut]\nURL=${pathToFileUrl(outputRoot)}\n`, "utf8");
|
|
133
|
+
console.log(`Created output shortcut: ${shortcutPath}`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
fs.symlinkSync(outputRoot, aliasPath, "dir");
|
|
138
|
+
console.log(`Created output alias: ${aliasPath}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const wrapperArgs = splitWrapperArgs(process.argv.slice(2));
|
|
142
|
+
|
|
94
143
|
ensureVenv();
|
|
95
144
|
ensureDependencies();
|
|
96
145
|
warnIfFfmpegMissing();
|
|
146
|
+
if (wrapperArgs.createDesktopOutputAlias) {
|
|
147
|
+
createDesktopOutputAlias();
|
|
148
|
+
}
|
|
97
149
|
|
|
98
|
-
const child = run(venvPython, [path.join(packageRoot, "media_tui.py"), ...
|
|
150
|
+
const child = run(venvPython, [path.join(packageRoot, "media_tui.py"), ...wrapperArgs.appArgs]);
|
|
99
151
|
if (child.signal) {
|
|
100
152
|
process.kill(process.pid, child.signal);
|
|
101
153
|
}
|
|
@@ -55,6 +55,11 @@ def get_cookies_from_browser() -> tuple[str, ...] | None:
|
|
|
55
55
|
|
|
56
56
|
def is_project_venv_active() -> bool:
|
|
57
57
|
active_prefix = Path(sys.prefix).resolve()
|
|
58
|
+
npm_venv = os.environ.get("MEDIA_INFORMATION_DOWNLOAD_VENV", "").strip()
|
|
59
|
+
if npm_venv:
|
|
60
|
+
expected_venv = Path(npm_venv).expanduser().resolve()
|
|
61
|
+
return active_prefix == expected_venv or expected_venv in active_prefix.parents
|
|
62
|
+
|
|
58
63
|
project_venv = (PROJECT_ROOT / ".venv").resolve()
|
|
59
64
|
return active_prefix == project_venv or project_venv in active_prefix.parents
|
|
60
65
|
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "media-information-download"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "Terminal app for downloading media from YouTube or RSS feeds, converting to MP3, and generating Whisper transcripts."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|