git-cli-yt 1.1.9 → 2.0.0
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/PRIVACY_POLICY.md +10 -0
- package/README.md +49 -1
- package/app.py +1322 -0
- package/audio/__init__.py +0 -0
- package/audio/audio_player.py +566 -0
- package/bin/cli.js +105 -67
- package/main.py +8 -682
- package/mix/__init__.py +0 -0
- package/mix/mix_service.py +227 -0
- package/package.json +32 -29
- package/requirements.txt +10 -8
- package/utils/__init__.py +0 -0
- package/utils/helpers.py +37 -0
- package/youtube/__init__.py +0 -0
- package/youtube/auth.py +196 -0
- package/youtube/liked.py +121 -0
- package/youtube/playlist.py +139 -0
- package/youtube/search.py +362 -0
package/bin/cli.js
CHANGED
|
@@ -1,67 +1,105 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const { execFileSync, spawn } = require("child_process");
|
|
8
|
+
|
|
9
|
+
const packageDir = path.join(__dirname, "..");
|
|
10
|
+
const isWindows = process.platform === "win32";
|
|
11
|
+
const venvDir = path.join(os.tmpdir(), "cli-yt-v2-venv");
|
|
12
|
+
const pythonExecutable = isWindows
|
|
13
|
+
? path.join(venvDir, "Scripts", "python.exe")
|
|
14
|
+
: path.join(venvDir, "bin", "python");
|
|
15
|
+
const mainPy = path.join(packageDir, "main.py");
|
|
16
|
+
const requirementsFile = path.join(packageDir, "requirements.txt");
|
|
17
|
+
|
|
18
|
+
function findPython() {
|
|
19
|
+
const candidates = isWindows
|
|
20
|
+
? [
|
|
21
|
+
["python", []],
|
|
22
|
+
["py", ["-3"]],
|
|
23
|
+
]
|
|
24
|
+
: [
|
|
25
|
+
["python3", []],
|
|
26
|
+
["python", []],
|
|
27
|
+
];
|
|
28
|
+
const check = [
|
|
29
|
+
"-c",
|
|
30
|
+
"import sys; raise SystemExit(0 if sys.version_info >= (3, 9) else 1)",
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
for (const [command, prefix] of candidates) {
|
|
34
|
+
try {
|
|
35
|
+
execFileSync(command, [...prefix, ...check], { stdio: "ignore" });
|
|
36
|
+
return { command, prefix };
|
|
37
|
+
} catch (_) {
|
|
38
|
+
// Próximo candidato.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw new Error("Python 3.9 ou superior não foi encontrado.");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function setupVenv(python) {
|
|
45
|
+
if (!fs.existsSync(pythonExecutable)) {
|
|
46
|
+
console.log("⚙️ Criando ambiente virtual Python isolado...");
|
|
47
|
+
execFileSync(
|
|
48
|
+
python.command,
|
|
49
|
+
[...python.prefix, "-m", "venv", venvDir],
|
|
50
|
+
{ stdio: "inherit", windowsHide: true },
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(requirementsFile)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const requirements = fs.readFileSync(requirementsFile);
|
|
59
|
+
const digest = crypto.createHash("sha256").update(requirements).digest("hex");
|
|
60
|
+
const stampFile = path.join(venvDir, `.requirements-${digest}`);
|
|
61
|
+
if (fs.existsSync(stampFile)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log("📦 Instalando dependências atualizadas...");
|
|
66
|
+
execFileSync(
|
|
67
|
+
pythonExecutable,
|
|
68
|
+
[
|
|
69
|
+
"-m",
|
|
70
|
+
"pip",
|
|
71
|
+
"install",
|
|
72
|
+
"--disable-pip-version-check",
|
|
73
|
+
"-r",
|
|
74
|
+
requirementsFile,
|
|
75
|
+
],
|
|
76
|
+
{ stdio: "inherit", windowsHide: true },
|
|
77
|
+
);
|
|
78
|
+
fs.writeFileSync(stampFile, digest, "utf8");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function runPlayer() {
|
|
82
|
+
const child = spawn(pythonExecutable, [mainPy], {
|
|
83
|
+
stdio: "inherit",
|
|
84
|
+
cwd: process.cwd(),
|
|
85
|
+
env: process.env,
|
|
86
|
+
windowsHide: true,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
child.on("error", (error) => {
|
|
90
|
+
console.error(`❌ Não foi possível iniciar o player: ${error.message}`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
child.on("exit", (code, signal) => {
|
|
94
|
+
process.exit(code === null ? (signal ? 1 : 0) : code);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const python = findPython();
|
|
100
|
+
setupVenv(python);
|
|
101
|
+
runPlayer();
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error(`❌ Erro: ${error.message}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|