-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_proxy.js
More file actions
27 lines (25 loc) · 967 Bytes
/
test_proxy.js
File metadata and controls
27 lines (25 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import youtubeDl from 'youtube-dl-exec';
async function run() {
console.log("Fetching proxies...");
const res = await fetch('https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt');
const text = await res.text();
const proxies = text.split('\n').filter(p => p.trim() !== '');
for (let i = 0; i < 5; i++) {
const randIndex = Math.floor(Math.random() * proxies.length);
const proxy = 'http://' + proxies[randIndex].trim();
try {
console.log("Trying proxy", proxy);
const output = await youtubeDl('https://www.youtube.com/watch?v=fJ9rUzIMcZQ', {
dumpJson: true,
noWarnings: true,
proxy: proxy,
socketTimeout: 10
});
console.log("SUCCESS WITH PROXY " + proxy + "! Title: " + output.title);
return;
} catch (e) {
console.log("Failed");
}
}
}
run();