@pieda/video-dl 1.7.0 → 1.8.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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
type TUseVimeo = {
|
|
2
|
+
ytdlpPath: string;
|
|
2
3
|
videoId: string;
|
|
3
4
|
dest: string;
|
|
4
5
|
downloadBtnSelector?: string;
|
|
5
6
|
debug?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const useVimeo: ({ videoId, dest, debug, }: TUseVimeo) => Promise<[Error | null, boolean | null]>;
|
|
8
|
+
export declare const useVimeo: ({ ytdlpPath, videoId, dest, debug, }: TUseVimeo) => Promise<[Error | null, boolean | null]>;
|
|
8
9
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type TUseYoutube = {
|
|
2
|
+
ytdlpPath: string;
|
|
2
3
|
videoId: string;
|
|
3
4
|
dest: string;
|
|
4
5
|
debug?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare const useYoutube: ({ videoId, dest, debug, }: TUseYoutube) => Promise<[Error | null, boolean | null]>;
|
|
7
|
+
export declare const useYoutube: ({ ytdlpPath, videoId, dest, debug, }: TUseYoutube) => Promise<[Error | null, boolean | null]>;
|
|
7
8
|
export {};
|
package/dist/video-dl.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=r=>new Promise((o,a)=>{import(r).then(g=>o(g.default)).catch(a)}),h=async(r,o,a)=>{const g=await l("fs"),e=await l("axios");return console.log(`Downloading ${r} to ${o}`),new Promise((u,s)=>{e.get(r,{responseType:"stream",headers:a}).then(c=>{const p=c.data,n=g.createWriteStream(o);p.pipe(n),n.on("finish",function(){n.close(()=>{u()})})}).catch(s)})},d=(r=!1)=>({log:(...o)=>{r&&console.log(...o)},error:(...o)=>{r&&console.error(...o)}}),$=async({ytdlpPath:r,videoId:o,dest:a,debug:g=!1})=>{const e=d(g);e.log(`Downloading video: ${o} to: ${a}`);const u=await l("fs"),s=await l("path"),{exec:c}=await l("child_process"),p=(n="")=>new Promise((w,t)=>{const i=`${r} -f b -g https://www.youtube.com/watch?v=${n}`;e.log(`[yt-dlp] 執行命令: ${i}`),c(i,(m,f,S)=>{if(e.log(`[yt-dlp] stdout: ${f}`),!f.includes("https://")){w("");return}w(f)})});return u.existsSync(s.dirname(a))||(u.mkdirSync(s.dirname(a),{recursive:!0},777),e.log(`建立 ${s.dirname(a)}`)),new Promise(async(n,w)=>{try{const t=await p(o);if(!t)throw new Error("無法取得 videoUrl");e.log(`取得 videoUrl ${t}`),await h(t,a).catch(i=>{throw e.error(`下載失敗: ${i.message}`),i}),e.log(`下載完成 ${a}`),n([null,!0])}catch(t){e.error(`下載失敗: ${t.message}`),n([t,null])}})},k=async({videoId:r,dest:o,debug:a=!1,headless:g=!0})=>{try{const e=d(a);e.log(`Downloading video: ${r} to: ${o}`);const u=`https://m.facebook.com/watch/?v=${r}`,s=await l("fs"),c=await l("path"),p=await l("puppeteer");s.existsSync(c.dirname(o))||(s.mkdirSync(c.dirname(o),{recursive:!0},777),e.log(`建立 ${c.dirname(o)}`));const n={};g||(n.headless=!1);const w=await p.launch(n);e.log("啟動 puppeteer");const t=await w.newPage();await t.setUserAgent("'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'"),e.log("開新分頁"),e.log(`前往 ${u}`),await Promise.race([t.goto(u,{waitUntil:"networkidle0"}),t.waitForSelector("video")]),e.log("找到 video 元素");const i=await t.$eval("video",m=>m.getAttribute("src"));return e.log(`取得 video url: ${i}`),await w.close(),e.log("關閉 puppeteer"),await h(i,o),e.log(`下載完成 ${i}`),[null,!0]}catch(e){return[e,null]}},v=async({ytdlpPath:r,videoId:o,dest:a,debug:g=!1})=>{const e=d(g);e.log(`Downloading video: ${o} to: ${a}`);const u=await l("fs"),s=await l("path"),{exec:c}=await l("child_process"),p=(n="")=>new Promise((w,t)=>{const i=`${r} -f b -g https://vimeo.com/${n}`;console.log(`執行命令: ${i}`),c(i,(m,f,S)=>{if(e.log(`yt-dlp stdout: ${f}`),!f.includes("https://")){w("");return}w(f)})});return u.existsSync(s.dirname(a))||(u.mkdirSync(s.dirname(a),{recursive:!0},777),e.log(`建立 ${s.dirname(a)}`)),new Promise(async(n,w)=>{try{const t=await p(o);if(!t)throw new Error("無法取得 videoUrl");e.log(`取得 videoUrl ${t}`),await h(t,a).catch(i=>{throw e.error(`下載失敗: ${i.message}`),i}),e.log(`下載完成 ${a}`),n([null,!0])}catch(t){e.error(`下載失敗: ${t.message}`),n([t,null])}})},y=async({videoId:r,dest:o,debug:a=!1,headless:g=!0})=>{try{const e=d(a);e.log(`Downloading video: ${r} to: ${o}`);const u=`https://www.instagram.com/reel/${r}/`,s=await l("fs"),c=await l("path"),p=await l("puppeteer");s.existsSync(c.dirname(o))||(s.mkdirSync(c.dirname(o),{recursive:!0},777),e.log(`建立 ${c.dirname(o)}`));const n={};g||(n.headless=!1);const w=await p.launch(n);e.log("啟動 puppeteer");const t=await w.newPage();await t.setUserAgent("'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'"),e.log("開新分頁"),e.log(`前往 ${u}`),await Promise.race([t.goto(u,{waitUntil:"networkidle0"}),t.waitForSelector("video")]),e.log("找到 video 元素");const i=await t.$eval("video",m=>m.getAttribute("src"));return e.log(`取得 video url: ${i}`),await w.close(),e.log("關閉 puppeteer"),await h(i,o),e.log(`下載完成 ${i}`),[null,!0]}catch(e){return[e,null]}},b=async({videoLink:r,dest:o,debug:a=!1,headless:g=!0})=>{try{const e=d(a);e.log(`Downloading video: ${r} to: ${o}`);const u=r,s=await l("fs"),c=await l("path"),p=await l("puppeteer");s.existsSync(c.dirname(o))||(s.mkdirSync(c.dirname(o),{recursive:!0},777),e.log(`建立 ${c.dirname(o)}`));const n={};g||(n.headless=!1);const w=await p.launch(n);e.log("啟動 puppeteer");const t=await w.newPage();e.log("開新分頁"),e.log(`前往 ${u}`),await Promise.race([t.goto(u,{waitUntil:"networkidle0"}),t.waitForSelector("video")]),e.log("找到 video 元素");const i=await t.$eval('video source[src^="https://www.tiktok.com/aweme/v1/play/"]',m=>m.getAttribute("src"));return e.log(`取得 video url: ${i}`),await w.close(),e.log("關閉 puppeteer"),await h(i,o,{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",Referer:"https://www.tiktok.com/"}),e.log(`下載完成 ${i}`),[null,!0]}catch(e){return[e,null]}},P=({type:r})=>{switch(r){case"youtube":case"yt-short":return $;case"facebook":case"fb-reel":return k;case"vimeo":return v;case"instagram":case"ig":case"ig-reel":return y;case"tiktok":case"tiktok-reel":return b;default:throw new Error(`Invalid video type: ${r}`)}};exports.useDownloader=P;exports.useFacebook=k;exports.useInstagram=y;exports.useTiktok=b;exports.useVimeo=v;exports.useYoutube=$;
|
package/dist/video-dl.js
CHANGED
|
@@ -1,219 +1,205 @@
|
|
|
1
|
-
const l = (
|
|
2
|
-
import(
|
|
3
|
-
}),
|
|
4
|
-
const
|
|
5
|
-
return console.log(`Downloading ${
|
|
6
|
-
e.get(
|
|
1
|
+
const l = (r) => new Promise((o, a) => {
|
|
2
|
+
import(r).then((u) => o(u.default)).catch(a);
|
|
3
|
+
}), f = async (r, o, a) => {
|
|
4
|
+
const u = await l("fs"), e = await l("axios");
|
|
5
|
+
return console.log(`Downloading ${r} to ${o}`), new Promise((w, c) => {
|
|
6
|
+
e.get(r, {
|
|
7
7
|
responseType: "stream",
|
|
8
|
-
headers:
|
|
8
|
+
headers: a
|
|
9
9
|
}).then((s) => {
|
|
10
|
-
const p = s.data,
|
|
11
|
-
p.pipe(
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const p = s.data, n = u.createWriteStream(o);
|
|
11
|
+
p.pipe(n), n.on("finish", function() {
|
|
12
|
+
n.close(() => {
|
|
13
|
+
w();
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
|
-
}).catch(
|
|
16
|
+
}).catch(c);
|
|
17
17
|
});
|
|
18
|
-
},
|
|
19
|
-
log: (...
|
|
20
|
-
|
|
18
|
+
}, $ = (r = !1) => ({
|
|
19
|
+
log: (...o) => {
|
|
20
|
+
r && console.log(...o);
|
|
21
21
|
},
|
|
22
|
-
error: (...
|
|
23
|
-
|
|
22
|
+
error: (...o) => {
|
|
23
|
+
r && console.error(...o);
|
|
24
24
|
}
|
|
25
|
-
}),
|
|
25
|
+
}), v = async ({
|
|
26
|
+
ytdlpPath: r,
|
|
26
27
|
videoId: o,
|
|
27
|
-
dest:
|
|
28
|
+
dest: a,
|
|
28
29
|
debug: u = !1
|
|
29
30
|
}) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const p = await s.download(o, {
|
|
39
|
-
type: "video+audio",
|
|
40
|
-
quality: "best",
|
|
41
|
-
format: "mp4",
|
|
42
|
-
client: "WEB"
|
|
43
|
-
}), a = e.createWriteStream(t);
|
|
44
|
-
for await (const g of y(p))
|
|
45
|
-
a.write(g);
|
|
46
|
-
return [null, !0];
|
|
47
|
-
} catch (p) {
|
|
48
|
-
return console.log("error", p), [p, null];
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
async function* y(o) {
|
|
52
|
-
const t = o.getReader();
|
|
53
|
-
try {
|
|
54
|
-
for (; ; ) {
|
|
55
|
-
const { done: u, value: i } = await t.read();
|
|
56
|
-
if (u)
|
|
31
|
+
const e = $(u);
|
|
32
|
+
e.log(`Downloading video: ${o} to: ${a}`);
|
|
33
|
+
const w = await l("fs"), c = await l("path"), { exec: s } = await l("child_process"), p = (n = "") => new Promise((g, t) => {
|
|
34
|
+
const i = `${r} -f b -g https://www.youtube.com/watch?v=${n}`;
|
|
35
|
+
e.log(`[yt-dlp] 執行命令: ${i}`), s(i, (m, h, d) => {
|
|
36
|
+
if (e.log(`[yt-dlp] stdout: ${h}`), !h.includes("https://")) {
|
|
37
|
+
g("");
|
|
57
38
|
return;
|
|
58
|
-
|
|
39
|
+
}
|
|
40
|
+
g(h);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return w.existsSync(c.dirname(a)) || (w.mkdirSync(c.dirname(a), { recursive: !0 }, 777), e.log(`建立 ${c.dirname(a)}`)), new Promise(async (n, g) => {
|
|
44
|
+
try {
|
|
45
|
+
const t = await p(o);
|
|
46
|
+
if (!t)
|
|
47
|
+
throw new Error("無法取得 videoUrl");
|
|
48
|
+
e.log(`取得 videoUrl ${t}`), await f(t, a).catch((i) => {
|
|
49
|
+
throw e.error(`下載失敗: ${i.message}`), i;
|
|
50
|
+
}), e.log(`下載完成 ${a}`), n([null, !0]);
|
|
51
|
+
} catch (t) {
|
|
52
|
+
e.error(`下載失敗: ${t.message}`), n([t, null]);
|
|
59
53
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
dest: t,
|
|
67
|
-
debug: u = !1,
|
|
68
|
-
headless: i = !0
|
|
54
|
+
});
|
|
55
|
+
}, y = async ({
|
|
56
|
+
videoId: r,
|
|
57
|
+
dest: o,
|
|
58
|
+
debug: a = !1,
|
|
59
|
+
headless: u = !0
|
|
69
60
|
}) => {
|
|
70
61
|
try {
|
|
71
|
-
const e =
|
|
72
|
-
e.log(`Downloading video: ${
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const g = await p.launch(
|
|
62
|
+
const e = $(a);
|
|
63
|
+
e.log(`Downloading video: ${r} to: ${o}`);
|
|
64
|
+
const w = `https://m.facebook.com/watch/?v=${r}`, c = await l("fs"), s = await l("path"), p = await l("puppeteer");
|
|
65
|
+
c.existsSync(s.dirname(o)) || (c.mkdirSync(s.dirname(o), { recursive: !0 }, 777), e.log(`建立 ${s.dirname(o)}`));
|
|
66
|
+
const n = {};
|
|
67
|
+
u || (n.headless = !1);
|
|
68
|
+
const g = await p.launch(n);
|
|
78
69
|
e.log("啟動 puppeteer");
|
|
79
|
-
const
|
|
80
|
-
await
|
|
70
|
+
const t = await g.newPage();
|
|
71
|
+
await t.setUserAgent(
|
|
81
72
|
"'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'"
|
|
82
|
-
), e.log("開新分頁"), e.log(`前往 ${
|
|
83
|
-
|
|
73
|
+
), e.log("開新分頁"), e.log(`前往 ${w}`), await Promise.race([
|
|
74
|
+
t.goto(w, {
|
|
84
75
|
waitUntil: "networkidle0"
|
|
85
76
|
}),
|
|
86
|
-
|
|
77
|
+
t.waitForSelector("video")
|
|
87
78
|
]), e.log("找到 video 元素");
|
|
88
|
-
const
|
|
89
|
-
return e.log(`取得 video url: ${
|
|
79
|
+
const i = await t.$eval("video", (m) => m.getAttribute("src"));
|
|
80
|
+
return e.log(`取得 video url: ${i}`), await g.close(), e.log("關閉 puppeteer"), await f(i, o), e.log(`下載完成 ${i}`), [null, !0];
|
|
90
81
|
} catch (e) {
|
|
91
82
|
return [e, null];
|
|
92
83
|
}
|
|
93
|
-
},
|
|
84
|
+
}, k = async ({
|
|
85
|
+
ytdlpPath: r,
|
|
94
86
|
videoId: o,
|
|
95
|
-
dest:
|
|
87
|
+
dest: a,
|
|
96
88
|
debug: u = !1
|
|
97
89
|
}) => {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
}), { jwt: g } = a.data;
|
|
107
|
-
return g || "";
|
|
108
|
-
}, p = async (a = "", g = "") => {
|
|
109
|
-
const r = await w.get(`https://api.vimeo.com/videos/${a}?&fields=download`, {
|
|
110
|
-
responseType: "json",
|
|
111
|
-
headers: {
|
|
112
|
-
"X-Requested-With": "XMLHttpRequest",
|
|
113
|
-
Authorization: `jwt ${g}`
|
|
90
|
+
const e = $(u);
|
|
91
|
+
e.log(`Downloading video: ${o} to: ${a}`);
|
|
92
|
+
const w = await l("fs"), c = await l("path"), { exec: s } = await l("child_process"), p = (n = "") => new Promise((g, t) => {
|
|
93
|
+
const i = `${r} -f b -g https://vimeo.com/${n}`;
|
|
94
|
+
console.log(`執行命令: ${i}`), s(i, (m, h, d) => {
|
|
95
|
+
if (e.log(`yt-dlp stdout: ${h}`), !h.includes("https://")) {
|
|
96
|
+
g("");
|
|
97
|
+
return;
|
|
114
98
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
return
|
|
99
|
+
g(h);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
return w.existsSync(c.dirname(a)) || (w.mkdirSync(c.dirname(a), { recursive: !0 }, 777), e.log(`建立 ${c.dirname(a)}`)), new Promise(async (n, g) => {
|
|
119
103
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
a([
|
|
104
|
+
const t = await p(o);
|
|
105
|
+
if (!t)
|
|
106
|
+
throw new Error("無法取得 videoUrl");
|
|
107
|
+
e.log(`取得 videoUrl ${t}`), await f(t, a).catch((i) => {
|
|
108
|
+
throw e.error(`下載失敗: ${i.message}`), i;
|
|
109
|
+
}), e.log(`下載完成 ${a}`), n([null, !0]);
|
|
110
|
+
} catch (t) {
|
|
111
|
+
e.error(`下載失敗: ${t.message}`), n([t, null]);
|
|
126
112
|
}
|
|
127
113
|
});
|
|
128
|
-
},
|
|
129
|
-
videoId:
|
|
130
|
-
dest:
|
|
131
|
-
debug:
|
|
132
|
-
headless:
|
|
114
|
+
}, S = async ({
|
|
115
|
+
videoId: r,
|
|
116
|
+
dest: o,
|
|
117
|
+
debug: a = !1,
|
|
118
|
+
headless: u = !0
|
|
133
119
|
}) => {
|
|
134
120
|
try {
|
|
135
|
-
const e =
|
|
136
|
-
e.log(`Downloading video: ${
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
const g = await p.launch(
|
|
121
|
+
const e = $(a);
|
|
122
|
+
e.log(`Downloading video: ${r} to: ${o}`);
|
|
123
|
+
const w = `https://www.instagram.com/reel/${r}/`, c = await l("fs"), s = await l("path"), p = await l("puppeteer");
|
|
124
|
+
c.existsSync(s.dirname(o)) || (c.mkdirSync(s.dirname(o), { recursive: !0 }, 777), e.log(`建立 ${s.dirname(o)}`));
|
|
125
|
+
const n = {};
|
|
126
|
+
u || (n.headless = !1);
|
|
127
|
+
const g = await p.launch(n);
|
|
142
128
|
e.log("啟動 puppeteer");
|
|
143
|
-
const
|
|
144
|
-
await
|
|
129
|
+
const t = await g.newPage();
|
|
130
|
+
await t.setUserAgent(
|
|
145
131
|
"'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'"
|
|
146
|
-
), e.log("開新分頁"), e.log(`前往 ${
|
|
147
|
-
|
|
132
|
+
), e.log("開新分頁"), e.log(`前往 ${w}`), await Promise.race([
|
|
133
|
+
t.goto(w, {
|
|
148
134
|
waitUntil: "networkidle0"
|
|
149
135
|
}),
|
|
150
|
-
|
|
136
|
+
t.waitForSelector("video")
|
|
151
137
|
]), e.log("找到 video 元素");
|
|
152
|
-
const
|
|
153
|
-
return e.log(`取得 video url: ${
|
|
138
|
+
const i = await t.$eval("video", (m) => m.getAttribute("src"));
|
|
139
|
+
return e.log(`取得 video url: ${i}`), await g.close(), e.log("關閉 puppeteer"), await f(i, o), e.log(`下載完成 ${i}`), [null, !0];
|
|
154
140
|
} catch (e) {
|
|
155
141
|
return [e, null];
|
|
156
142
|
}
|
|
157
|
-
},
|
|
158
|
-
videoLink:
|
|
159
|
-
dest:
|
|
160
|
-
debug:
|
|
161
|
-
headless:
|
|
143
|
+
}, b = async ({
|
|
144
|
+
videoLink: r,
|
|
145
|
+
dest: o,
|
|
146
|
+
debug: a = !1,
|
|
147
|
+
headless: u = !0
|
|
162
148
|
}) => {
|
|
163
149
|
try {
|
|
164
|
-
const e =
|
|
165
|
-
e.log(`Downloading video: ${
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
const g = await p.launch(
|
|
150
|
+
const e = $(a);
|
|
151
|
+
e.log(`Downloading video: ${r} to: ${o}`);
|
|
152
|
+
const w = r, c = await l("fs"), s = await l("path"), p = await l("puppeteer");
|
|
153
|
+
c.existsSync(s.dirname(o)) || (c.mkdirSync(s.dirname(o), { recursive: !0 }, 777), e.log(`建立 ${s.dirname(o)}`));
|
|
154
|
+
const n = {};
|
|
155
|
+
u || (n.headless = !1);
|
|
156
|
+
const g = await p.launch(n);
|
|
171
157
|
e.log("啟動 puppeteer");
|
|
172
|
-
const
|
|
173
|
-
e.log("開新分頁"), e.log(`前往 ${
|
|
174
|
-
|
|
158
|
+
const t = await g.newPage();
|
|
159
|
+
e.log("開新分頁"), e.log(`前往 ${w}`), await Promise.race([
|
|
160
|
+
t.goto(w, {
|
|
175
161
|
waitUntil: "networkidle0"
|
|
176
162
|
}),
|
|
177
|
-
|
|
163
|
+
t.waitForSelector("video")
|
|
178
164
|
]), e.log("找到 video 元素");
|
|
179
|
-
const
|
|
165
|
+
const i = await t.$eval(
|
|
180
166
|
'video source[src^="https://www.tiktok.com/aweme/v1/play/"]',
|
|
181
|
-
(
|
|
167
|
+
(m) => m.getAttribute("src")
|
|
182
168
|
);
|
|
183
|
-
return e.log(`取得 video url: ${
|
|
169
|
+
return e.log(`取得 video url: ${i}`), await g.close(), e.log("關閉 puppeteer"), await f(i, o, {
|
|
184
170
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
185
171
|
Referer: "https://www.tiktok.com/"
|
|
186
172
|
// 設定 Referer
|
|
187
|
-
}), e.log(`下載完成 ${
|
|
173
|
+
}), e.log(`下載完成 ${i}`), [null, !0];
|
|
188
174
|
} catch (e) {
|
|
189
175
|
return [e, null];
|
|
190
176
|
}
|
|
191
|
-
},
|
|
192
|
-
switch (
|
|
177
|
+
}, P = ({ type: r }) => {
|
|
178
|
+
switch (r) {
|
|
193
179
|
case "youtube":
|
|
194
180
|
case "yt-short":
|
|
195
|
-
return
|
|
181
|
+
return v;
|
|
196
182
|
case "facebook":
|
|
197
183
|
case "fb-reel":
|
|
198
|
-
return
|
|
184
|
+
return y;
|
|
199
185
|
case "vimeo":
|
|
200
|
-
return
|
|
186
|
+
return k;
|
|
201
187
|
case "instagram":
|
|
202
188
|
case "ig":
|
|
203
189
|
case "ig-reel":
|
|
204
|
-
return
|
|
190
|
+
return S;
|
|
205
191
|
case "tiktok":
|
|
206
192
|
case "tiktok-reel":
|
|
207
|
-
return
|
|
193
|
+
return b;
|
|
208
194
|
default:
|
|
209
|
-
throw new Error(`Invalid video type: ${
|
|
195
|
+
throw new Error(`Invalid video type: ${r}`);
|
|
210
196
|
}
|
|
211
197
|
};
|
|
212
198
|
export {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
199
|
+
P as useDownloader,
|
|
200
|
+
y as useFacebook,
|
|
201
|
+
S as useInstagram,
|
|
202
|
+
b as useTiktok,
|
|
203
|
+
k as useVimeo,
|
|
204
|
+
v as useYoutube
|
|
219
205
|
};
|