-
Notifications
You must be signed in to change notification settings - Fork 0
/
Telugupalaka.js
408 lines (307 loc) · 9.24 KB
/
Telugupalaka.js
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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//telugupakala
const puppeteer = require('puppeteer');
const readline = require('readline');
const ora = require('ora');
const chalk = require('chalk');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
global.MOvie = "";
global.ShrinkLinks = "";
///prompt.start();
//console.log('Please Enter MOvie name:');
console.log(chalk.white.bgCyan.bold('Please provide the movie name'));
rl.question(':', (MovieName) => {
MOvie = MovieName;
MOvie = "+" + MOvie + "+";
puppeteer
.launch({
headless: true,
executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", ///provide your chrome path
args: [
'--safebrowsing-disable-auto-update',
"--proxy-server='direct://",
"--proxy-bypass-list=*"
]
}
)
.then(async browser => {
const spinner = new ora({
text: 'Loading unicorns',
spinner: "dots12"
});
spinner.start();
setTimeout(() => {
spinner.color = 'green';
spinner.text = 'Please wait ...';
}, 10);
//call to browser
var url = "https://duckduckgo.com/?q=" + MOvie + "site%3Atelugupalaka.com/";
///duckduck go
DuckDuckGo(url, browser).
then(DuckDuckGoUrl => {
spinner.stop();
if (DuckDuckGoUrl === 0) {
console.log("\n" + chalk.bgRed.bold("No Movie with name " + MovieName + " found !"));
process.exit(1);
}
TelugupalakaPage(DuckDuckGoUrl, browser)
.then(b => {
var f = b;
rl.question('Select an option : ', (answer2) => {
var selectedUrl = f[answer2].toString().split("->")[1];
//console.log(selectedUrl);
LinkSharenet(selectedUrl, browser).then(v => {
//console.log("Hashed code "+v);
var hashcode = revC(v);
OpenLoad(hashcode, browser).then(z => {
//provide an option to download or view
var download_url = "https://openload.co/stream/" + z.trim();
console.log(chalk.bgGreen.bold("Use this url to download the video ") +"\n"+ chalk.bgGreen.bold.underline(download_url));
});
});
rl.close();
});
});
});
////end duckduckgo and telugupalaka
});
});
async function DuckDuckGo(url, browser) {
try {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
if (['image'].indexOf(request.resourceType()) !== -1) {
request.abort();
} else {
request.continue();
}
});
await page.goto(url, {
timeout: 0
});
const hrefs = await page.$$eval('a.result__a', hrefs => hrefs.map((a) => {
return a.href;
}));
var link = hrefs[0];
if (typeof link == "undefined") {
//page.close();
return 0;
} else {
//page.close();
return link;
}
// process.exit(1);
} catch (err) {
console.error(err);
}
}
///Telugu palaka Page
async function TelugupalakaPage(url, browser) {
try {
const page1 = await browser.newPage();
await page1.setRequestInterception(true);
page1.on('request', (request) => {
if (['image', 'stylesheet', 'font', 'script'].indexOf(request.resourceType()) !== -1) {
request.abort();
} else {
request.continue();
}
});
await page1.goto(url, {
timeout: 0
});
///print title of the page
const chalk = require('chalk');
const Title = await page1.evaluate(() => document.querySelector('h1').textContent);
console.log(chalk.bgYellow.bold(Title));
console.log(chalk.bgRed.bold("If it's not the movie press Ctrl+c to exit,and provide full movie name."));
const hrefs = await page1.$$eval('a[target]', aTags => aTags.map(a => {
let textC = a.textContent;
if (textC.match(/.*Watch.*/)) {
var rep = textC.replace('Watch', 'Download');
return rep + "->" + a.getAttribute("href");
}
}));
var f = hrefs.filter(item => item);
//console.log(f);
console.log("\n"+chalk.white.bgRed.bold.underline('option ') + chalk.yellow.bgBlue.bold.underline('content'.padStart(40)));
let y = 0;
for (let g of f)
console.log("" + chalk.white.bgRed.bold((y++) + " ") + chalk.yellow.bgBlue.bold(g.toString().split("->")[0].padStart(40)));
return f;
} catch (err) {
console.error(err);
}
}
///Linkshare.net page
async function LinkSharenet(url, browser) {
try {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
if (['image', 'stylesheet', 'font', 'script'].indexOf(request.resourceType()) !== -1) {
request.abort();
} else {
request.continue();
}
});
await page.goto(url, {
timeout: 0
});
//get the recV from scrapping
let bodyHTML = await page.evaluate(() => document.body.textContent);
var reg = /(revC\(".*"\))/;
var m1 = bodyHTML.toString().match(reg);
var m11 = m1[0];
var m2 = m11.toString().match(/(".*")/);
//console.log(m11+" "+m2[0]);
return m2[0];
} catch (err) {
console.error(err);
}
}
///Openload.net page
async function OpenLoad(url, browser) {
const chalk = require('chalk');
try {
const opage = await browser.newPage();
await opage.setRequestInterception(true);
opage.on('request', (request) => {
if (['image'].indexOf(request.resourceType()) !== -1) {
request.abort();
} else {
request.continue();
}
});
const spinner = new ora({
text: 'Loading unicorns',
spinner: "dots12"
});
spinner.start();
setTimeout(() => {
spinner.color = 'green';
spinner.text = 'Extracting Url from openload page ...';
}, 10);
try {
//wait for 15 sec else reload
await opage.goto(url, {
timeout: 35000
});
} catch (err) {
//console.log("page not loaded in 15 sec, reloading ");
await opage.reload({
timeout: 30000
});
//console.log("Completed loading page ");
// console.log(err);
}
spinner.stop();
//check if it is openload base url
try {
var textContentID = await opage.evaluate(() => document.querySelector('#DtsBlkVFQx').textContent);
} catch (e) {
console.log(chalk.bgRed.bold("Sorry video not found in OpenLoad site !"));
process.exit(1);
}
browser.close();
return textContentID;
} catch (err) {
console.error(err);
}
}
function revC(ine) {
var b64 = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode: function(e) {
var t = "";
var n, r, i, s, o, u, a;
var f = 0;
e = b64._utf8_encode(e);
while (f < e.length) {
n = e.charCodeAt(f++);
r = e.charCodeAt(f++);
i = e.charCodeAt(f++);
s = n >> 2;
o = (n & 3) << 4 | r >> 4;
u = (r & 15) << 2 | i >> 6;
a = i & 63;
if (isNaN(r)) {
u = a = 64
} else if (isNaN(i)) {
a = 64
}
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a)
}
return t
},
decode: function(e) {
var t = "";
var n, r, i;
var s, o, u, a;
var f = 0;
e = e.replace(/[^A-Za-z0-9+/=]/g, "");
while (f < e.length) {
s = this._keyStr.indexOf(e.charAt(f++));
o = this._keyStr.indexOf(e.charAt(f++));
u = this._keyStr.indexOf(e.charAt(f++));
a = this._keyStr.indexOf(e.charAt(f++));
n = s << 2 | o >> 4;
r = (o & 15) << 4 | u >> 2;
i = (u & 3) << 6 | a;
t = t + String.fromCharCode(n);
if (u != 64) {
t = t + String.fromCharCode(r)
}
if (a != 64) {
t = t + String.fromCharCode(i)
}
}
t = b64._utf8_decode(t);
return t
},
_utf8_encode: function(e) {
e = e.replace(/rn/g, "n");
var t = "";
for (var n = 0; n < e.length; n++) {
var r = e.charCodeAt(n);
if (r < 128) {
t += String.fromCharCode(r)
} else if (r > 127 && r < 2048) {
t += String.fromCharCode(r >> 6 | 192);
t += String.fromCharCode(r & 63 | 128)
} else {
t += String.fromCharCode(r >> 12 | 224);
t += String.fromCharCode(r >> 6 & 63 | 128);
t += String.fromCharCode(r & 63 | 128)
}
}
return t
},
_utf8_decode: function(e) {
var t = "";
var n = 0;
var r = c1 = c2 = 0;
while (n < e.length) {
r = e.charCodeAt(n);
if (r < 128) {
t += String.fromCharCode(r);
n++
} else if (r > 191 && r < 224) {
c2 = e.charCodeAt(n + 1);
t += String.fromCharCode((r & 31) << 6 | c2 & 63);
n += 2
} else {
c2 = e.charCodeAt(n + 1);
c3 = e.charCodeAt(n + 2);
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
n += 3
}
}
return t
}
};
return 'http://linkshrink.net/' + b64.decode(ine);
}