xvideo-dll 1.0.0 → 1.0.1
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 +65 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# xvideo-
|
|
1
|
+
# xvideo-dll
|
|
2
2
|
|
|
3
3
|
Librería para Node.js que obtiene la información y las resoluciones disponibles de un video y lo descarga.
|
|
4
4
|
|
|
@@ -15,48 +15,81 @@ Librería para Node.js que obtiene la información y las resoluciones disponible
|
|
|
15
15
|
## Instalación
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install xvideo-
|
|
18
|
+
npm install xvideo-dll
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Prueba rápida
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
import { fetchPageHtml, parseVideo, getResolutions, download } from "xvideo-download";
|
|
23
|
+
1. Crea una carpeta e instala el paquete:
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
```bash
|
|
26
|
+
mkdir prueba && cd prueba
|
|
27
|
+
npm init -y
|
|
28
|
+
npm install xvideo-dll
|
|
29
|
+
```
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
const html = await fetchPageHtml(pageUrl);
|
|
31
|
+
2. Crea un archivo `ejemplo.mjs` (la extensión `.mjs` permite usar `await` e `import` sin configurar nada):
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// { title, thumbnail, description, jsonLd }
|
|
33
|
+
```js
|
|
34
|
+
import { fetchPageHtml, parseVideo, getResolutions, download } from "xvideo-dll";
|
|
34
35
|
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// La URL de la página y (opcional) la resolución se pasan por la terminal
|
|
37
|
+
const pageUrl = process.argv[2];
|
|
38
|
+
if (!pageUrl) {
|
|
39
|
+
console.error('Uso: node ejemplo.mjs "URL_DE_LA_PAGINA" [resolucion]');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
39
42
|
|
|
40
|
-
//
|
|
41
|
-
const
|
|
42
|
-
const result = await download(
|
|
43
|
-
resolutions[key],
|
|
44
|
-
"video.mp4",
|
|
45
|
-
(p) => console.log(`${Math.round(p * 100)}%`), // progreso (0 a 1)
|
|
46
|
-
8, // conexiones en paralelo (solo HLS)
|
|
47
|
-
async () => { // opcional: renovar la URL si caduca
|
|
48
|
-
const fresh = await getResolutions(await fetchPageHtml(pageUrl));
|
|
49
|
-
return fresh[key];
|
|
50
|
-
}
|
|
51
|
-
);
|
|
43
|
+
// 1. Descargar la página (siempre en vivo: las URLs caducan)
|
|
44
|
+
const html = await fetchPageHtml(pageUrl);
|
|
52
45
|
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
// 2. Información básica
|
|
47
|
+
console.log(parseVideo(html));
|
|
48
|
+
|
|
49
|
+
// 3. Resoluciones disponibles
|
|
50
|
+
const resolutions = await getResolutions(html);
|
|
51
|
+
console.log("Disponibles:", Object.keys(resolutions));
|
|
52
|
+
|
|
53
|
+
// 4. Elegir una (por defecto la más ligera, "mp4-low") y descargarla
|
|
54
|
+
const key = process.argv[3] ?? "mp4-low";
|
|
55
|
+
if (!resolutions[key]) {
|
|
56
|
+
console.error(`La resolución "${key}" no existe.`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const result = await download(
|
|
61
|
+
resolutions[key],
|
|
62
|
+
`video-${key}.mp4`,
|
|
63
|
+
(p) => process.stdout.write(`\r${Math.round(p * 100)}%`), // progreso (0 a 1)
|
|
64
|
+
8, // conexiones en paralelo (solo HLS)
|
|
65
|
+
async () => { // opcional: renovar la URL si caduca
|
|
66
|
+
const fresh = await getResolutions(await fetchPageHtml(pageUrl));
|
|
67
|
+
return fresh[key];
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
console.log(`\nGuardado en ${result.path} (${(result.bytes / 1024 / 1024).toFixed(1)} MB)`);
|
|
72
|
+
```
|
|
55
73
|
|
|
56
|
-
|
|
74
|
+
3. Ejecútalo:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
node ejemplo.mjs "URL_DE_LA_PAGINA" # descarga la calidad mp4-low
|
|
78
|
+
node ejemplo.mjs "URL_DE_LA_PAGINA" hls-480p # o una resolución concreta
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
También funciona con `require`, dentro de una función `async` (CommonJS no permite `await` en el nivel superior):
|
|
57
82
|
|
|
58
83
|
```js
|
|
59
|
-
const { fetchPageHtml, getResolutions, download } = require("xvideo-
|
|
84
|
+
const { fetchPageHtml, getResolutions, download } = require("xvideo-dll");
|
|
85
|
+
|
|
86
|
+
async function main() {
|
|
87
|
+
const html = await fetchPageHtml(process.argv[2]);
|
|
88
|
+
const resolutions = await getResolutions(html);
|
|
89
|
+
await download(resolutions["mp4-low"], "video.mp4");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main();
|
|
60
93
|
```
|
|
61
94
|
|
|
62
95
|
## API
|
|
@@ -86,4 +119,4 @@ Todas las funciones y los tipos `VideoInfo` y `Resolutions` se exportan.
|
|
|
86
119
|
|
|
87
120
|
## Licencia
|
|
88
121
|
|
|
89
|
-
ISC
|
|
122
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xvideo-dll",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Obtiene la info y las resoluciones de un video y lo descarga (MP4 directo o HLS convertido a MP4 real) sin necesitar ffmpeg.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|