@irithell-js/yt-play 0.2.3 → 0.2.6
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 +142 -7
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -9
- package/dist/index.d.ts +37 -9
- package/dist/index.mjs +5 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
- package/scripts/check-ytdlp-update.mjs +150 -0
- package/scripts/setup-binaries.mjs +93 -24
- package/bin/.platform +0 -1
- package/bin/aria2c +0 -0
- package/bin/yt-dlp +0 -0
|
@@ -11,7 +11,6 @@ const __dirname = path.dirname(__filename);
|
|
|
11
11
|
|
|
12
12
|
const BINS_DIR = path.join(__dirname, "..", "bin");
|
|
13
13
|
const ARIA2_VERSION = "1.37.0";
|
|
14
|
-
const YTDLP_VERSION = "2025.12.08";
|
|
15
14
|
const PLATFORM_FILE = path.join(BINS_DIR, ".platform");
|
|
16
15
|
|
|
17
16
|
const ARIA2_BINARIES = {
|
|
@@ -30,21 +29,63 @@ const ARIA2_BINARIES = {
|
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
// Função para buscar a versão mais recente do yt-dlp
|
|
33
|
+
async function getLatestYtDlpVersion() {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const options = {
|
|
36
|
+
hostname: "api.github.com",
|
|
37
|
+
path: "/repos/yt-dlp/yt-dlp/releases/latest",
|
|
38
|
+
headers: {
|
|
39
|
+
"User-Agent": "yt-play-setup-script",
|
|
40
|
+
Accept: "application/vnd.github+json",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
https
|
|
45
|
+
.get(options, (response) => {
|
|
46
|
+
let data = "";
|
|
47
|
+
|
|
48
|
+
response.on("data", (chunk) => {
|
|
49
|
+
data += chunk;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
response.on("end", () => {
|
|
53
|
+
try {
|
|
54
|
+
const release = JSON.parse(data);
|
|
55
|
+
const version = release.tag_name; // Ex: "2026.02.04"
|
|
56
|
+
console.log(`✓ Latest yt-dlp version found: ${version}`);
|
|
57
|
+
resolve(version);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("✗ Failed to parse GitHub API response");
|
|
60
|
+
reject(error);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
})
|
|
64
|
+
.on("error", (error) => {
|
|
65
|
+
console.error("✗ Failed to fetch latest yt-dlp version");
|
|
66
|
+
reject(error);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Função para gerar URLs dos binários
|
|
72
|
+
function getYtDlpBinaries(version) {
|
|
73
|
+
return {
|
|
74
|
+
linux: {
|
|
75
|
+
x64: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_linux`,
|
|
76
|
+
arm64: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_linux_aarch64`,
|
|
77
|
+
},
|
|
78
|
+
darwin: {
|
|
79
|
+
x64: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_macos`,
|
|
80
|
+
arm64: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_macos`,
|
|
81
|
+
},
|
|
82
|
+
win32: {
|
|
83
|
+
x64: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp.exe`,
|
|
84
|
+
ia32: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_x86.exe`,
|
|
85
|
+
arm64: `https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_arm64.exe`,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
48
89
|
|
|
49
90
|
function download(url, dest) {
|
|
50
91
|
return new Promise((resolve, reject) => {
|
|
@@ -95,10 +136,12 @@ async function setupAria2c(platform, arch) {
|
|
|
95
136
|
);
|
|
96
137
|
|
|
97
138
|
if (fs.existsSync(aria2cPath)) {
|
|
139
|
+
console.log("✓ aria2c already exists");
|
|
98
140
|
return;
|
|
99
141
|
}
|
|
100
142
|
|
|
101
143
|
try {
|
|
144
|
+
console.log("⬇ Downloading aria2c...");
|
|
102
145
|
const url = ARIA2_BINARIES[platform][arch];
|
|
103
146
|
const zipPath = path.join(BINS_DIR, "aria2.zip");
|
|
104
147
|
|
|
@@ -115,13 +158,14 @@ async function setupAria2c(platform, arch) {
|
|
|
115
158
|
}
|
|
116
159
|
|
|
117
160
|
fs.unlinkSync(zipPath);
|
|
161
|
+
console.log("✓ aria2c installed successfully");
|
|
118
162
|
} catch (error) {
|
|
119
|
-
|
|
163
|
+
console.error("✗ Failed to install aria2c:", error.message);
|
|
120
164
|
}
|
|
121
165
|
}
|
|
122
166
|
|
|
123
|
-
async function setupYtDlp(platform, arch) {
|
|
124
|
-
if (!
|
|
167
|
+
async function setupYtDlp(platform, arch, ytdlpBinaries) {
|
|
168
|
+
if (!ytdlpBinaries[platform] || !ytdlpBinaries[platform][arch]) {
|
|
125
169
|
return;
|
|
126
170
|
}
|
|
127
171
|
|
|
@@ -130,29 +174,37 @@ async function setupYtDlp(platform, arch) {
|
|
|
130
174
|
platform === "win32" ? "yt-dlp.exe" : "yt-dlp",
|
|
131
175
|
);
|
|
132
176
|
|
|
177
|
+
// Sempre remove o binário antigo para forçar atualização
|
|
133
178
|
if (fs.existsSync(ytdlpPath)) {
|
|
134
|
-
|
|
179
|
+
console.log("⚠ Removing old yt-dlp binary...");
|
|
180
|
+
fs.unlinkSync(ytdlpPath);
|
|
135
181
|
}
|
|
136
182
|
|
|
137
183
|
try {
|
|
138
|
-
|
|
184
|
+
console.log("⬇ Downloading yt-dlp...");
|
|
185
|
+
const url = ytdlpBinaries[platform][arch];
|
|
139
186
|
await download(url, ytdlpPath);
|
|
140
187
|
|
|
141
188
|
if (platform !== "win32") {
|
|
142
189
|
fs.chmodSync(ytdlpPath, 0o755);
|
|
143
190
|
}
|
|
191
|
+
|
|
192
|
+
console.log("✓ yt-dlp installed successfully");
|
|
144
193
|
} catch (error) {
|
|
145
|
-
|
|
194
|
+
console.error("✗ Failed to install yt-dlp:", error.message);
|
|
146
195
|
}
|
|
147
196
|
}
|
|
148
197
|
|
|
149
198
|
async function setup() {
|
|
199
|
+
console.log("🚀 Starting binaries setup...\n");
|
|
200
|
+
|
|
150
201
|
const platform = process.platform;
|
|
151
202
|
const arch = process.arch;
|
|
152
203
|
const currentPlatform = getCurrentPlatform();
|
|
153
204
|
const savedPlatform = getPlatformFromFile();
|
|
154
205
|
|
|
155
206
|
if (savedPlatform && savedPlatform !== currentPlatform) {
|
|
207
|
+
console.log("⚠ Platform changed, cleaning old binaries...");
|
|
156
208
|
try {
|
|
157
209
|
const files = fs.readdirSync(BINS_DIR);
|
|
158
210
|
for (const file of files) {
|
|
@@ -167,11 +219,28 @@ async function setup() {
|
|
|
167
219
|
|
|
168
220
|
fs.mkdirSync(BINS_DIR, { recursive: true });
|
|
169
221
|
|
|
170
|
-
|
|
222
|
+
// Busca a versão mais recente do yt-dlp
|
|
223
|
+
let ytdlpVersion;
|
|
224
|
+
try {
|
|
225
|
+
ytdlpVersion = await getLatestYtDlpVersion();
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error("✗ Failed to fetch latest version, using fallback");
|
|
228
|
+
ytdlpVersion = "2026.02.04"; // Fallback version
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const ytdlpBinaries = getYtDlpBinaries(ytdlpVersion);
|
|
232
|
+
|
|
233
|
+
await Promise.all([
|
|
234
|
+
setupAria2c(platform, arch),
|
|
235
|
+
setupYtDlp(platform, arch, ytdlpBinaries),
|
|
236
|
+
]);
|
|
171
237
|
|
|
172
238
|
savePlatform();
|
|
239
|
+
|
|
240
|
+
console.log("\n✓ Setup completed successfully!");
|
|
173
241
|
}
|
|
174
242
|
|
|
175
|
-
setup().catch(() => {
|
|
243
|
+
setup().catch((error) => {
|
|
244
|
+
console.error("✗ Setup failed:", error);
|
|
176
245
|
process.exit(0);
|
|
177
246
|
});
|
package/bin/.platform
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
linux-x64
|
package/bin/aria2c
DELETED
|
Binary file
|
package/bin/yt-dlp
DELETED
|
Binary file
|