Yuuki0125 commited on
Commit
75a57fa
·
verified ·
1 Parent(s): bcdd7cf

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +70 -1211
main.py CHANGED
@@ -1,1219 +1,78 @@
1
- // Time & Date
2
- const moment = require('moment-timezone');
3
- moment.tz.setDefault("Asia/Kuala_Lumpur");
4
-
5
- // Tanggal
6
- const Tanggal = moment().format('DD-MM-YYYY');
7
-
8
- // Waktu
9
- const Jam = moment().format('HH:mm');
10
-
11
- // Runtime
12
- const startedAt = moment.tz("Asia/Jakarta");
13
- const now = moment.tz("Asia/Jakarta");
14
- const duration = moment.duration(now.diff(startedAt));
15
- const runtime = `${duration.hours()}:${duration.minutes()}:${duration.seconds()}`;
16
-
17
- const BotInfo = `
18
- 「 *Monika AI* 」
19
-
20
- ╠┈┈「 *Info Bot*
21
- ╎❏ *Bot Name:* Monika
22
- ╎❏ *Creator:* Another
23
- ╎❏ *Language:* Node.Js & Python
24
- ╎❏ *Time:* ${Jam}
25
- ╎❏ *Date:* ${Tanggal}
26
- ╎❏ *Runtime:* ${runtime}
27
- ╚┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈❖
28
-
29
- ╠┈┈┈┈「 *Menu* 」┈┈┈┈❖
30
-
31
- ╠┈┈「 *AI* 」
32
- ╎❏ *GPT:* monika/noir
33
- ╎❏ *C.AI:* an/al
34
- ╎❏ *Stable Defusion:* art/txt2img
35
- ╎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈❖
36
- ╠┈┈「 *Downloader* 」
37
- ╎❏ *YT:* ytmp4/ytmp3
38
- ╎❏ *FB:* fb
39
- ╎❏ *Pinterest:* pin
40
- ╎❏ *NHentai:* nh
41
- ╎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈❖
42
- ╠┈┈「 *Tools* 」
43
- ╎❏ *Sticker:* s/sticker
44
- ╎❏ *Sticker To Img:* ti
45
- ╎❏ *Upscaler:* upscale/2x
46
- ╎❏ *View:* view
47
- ╎❏ *Sauce Anime Scane:* sauce
48
- ╎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈❖
49
- ╠┈┈「 *Search* 」
50
- ╎❏ *Pinterest Search:* pinsc
51
- ╎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈❖
52
- ╠┈┈「 *MISC* 」
53
- ╎❏ *Random Waifu:* waifu/neko
54
- ╎❏ *Random Char:* randomchar
55
- ╎❏ *Random Anime:* randomanime
56
- ╎❏ *NSFW:* nsfw/hneko
57
- ╚┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈❖`;
58
-
59
- //----------------------------------------------------------------------------------\\
60
-
61
- const express = require('express');
62
- const app = express();
63
- const PORT = process.env.PORT || 7860;
64
-
65
-
66
- // WhatsApp Bot Code ---------------------------
67
- const { default: makeWASocket, useMultiFileAuthState, downloadContentFromMessage } = require("@whiskeysockets/baileys");
68
- const Pino = require("pino");
69
- const fs = require("fs");
70
- const ffmpeg = require('fluent-ffmpeg');
71
- const path = require('path');
72
- const sharp = require('sharp');
73
- const fetch = require('node-fetch');
74
- const axios = require('axios')
75
- const cheerio = require('cheerio');
76
- const api_key = "df2e12cdd170b47344738acca42d6fd42becf93a";
77
-
78
- //Media Path
79
- const Media = "tmp/media";
80
-
81
- //Fungsi Untuk Menghapus file --------------------------------------------
82
- const folderPath = 'tmp/media';
83
-
84
- const deleteFilesInFolder = (folderPath) => {
85
- fs.readdirSync(folderPath).forEach((file) => {
86
- const filePath = path.join(folderPath, file);
87
-
88
- try {
89
- fs.unlinkSync(filePath);
90
- console.log(`File ${filePath} berhasil dihapus`);
91
- } catch (err) {
92
- console.error(`Gagal menghapus file ${filePath}: ${err.message}`);
93
- }
94
- });
95
- };
96
- // -----------------------------------------------------------------------
97
-
98
- const useCODE = process.argv.includes("--useCODE");
99
-
100
- let creds;
101
-
102
- try {
103
- creds = JSON.parse(fs.readFileSync("./tmp/auth/creds.json"));
104
- } catch (err) {
105
- creds = null;
106
- }
107
-
108
- async function connectToWhatsapp() {
109
- const auth = await useMultiFileAuthState("tmp/auth");
110
-
111
- let browser;
112
-
113
- if (!creds) {
114
- browser = useCODE ? ["Chrome (Linux)", "", ""] : ["Sibay", "Firefox", "1.0.0"];
115
- } else {
116
- browser = !creds.pairingCode || creds.pairingCode === "" ? ["Sibay", "Firefox", "1.0.0"] : ["Chrome (Linux)", "", ""];
117
- }
118
-
119
- console.log(browser);
120
-
121
- const socket = makeWASocket({
122
- printQRInTerminal: !useCODE,
123
- browser: browser,
124
- auth: auth.state,
125
- logger: Pino({ level: "silent" }),
126
- generateHighQualityLinkPreview: true
127
- });
128
-
129
- if (useCODE && !socket.user && !socket.authState.creds.registered) {
130
- const question = pertanyaan =>
131
- new Promise(resolve => {
132
- const readline = require("readline").createInterface({
133
- input: process.stdin,
134
- output: process.stdout
135
- });
136
- readline.question(pertanyaan, answer => {
137
- resolve(answer);
138
- readline.close();
139
- });
140
- });
141
-
142
- const Nomor_Bot = "6287843194595";
143
-
144
- setTimeout(async function () {
145
- const pairingCode = await socket.requestPairingCode(Nomor_Bot);
146
- console.log("Pairing code anda: ", pairingCode);
147
- }, 3000);
148
- }
149
-
150
- socket.ev.on("creds.update", auth.saveCreds);
151
- socket.ev.on("connection.update", ({ connection }) => {
152
- if (connection === "open") console.log("Nomor WA Yang Terhubung: " + socket.user.id.split(":")[0]);
153
- if (connection === "close") connectToWhatsapp();
154
- });
155
-
156
- const myNumber = "62895805188618";
157
- const processed = [];
158
-
159
- socket.ev.on("messages.upsert", ({ messages }) => {
160
- const msg = messages[0];
161
-
162
- if(processed.includes(msg.key.id)) return;
163
- processed.push(msg.key.id);
164
-
165
- if(msg.key.remoteJid.endsWith(myNumber + '@s.whatsapp.net')) {
166
- // nomor pengirim sama, lanjutkan
167
-
168
- }
169
- // cek grup chat
170
- else if(msg.key.remoteJid.includes('@g.us')) {
171
- if(msg.key.participant.endsWith(myNumber + '@s.whatsapp.net')) {
172
- // nomor pengirim di grup sama, lanjutkan
173
-
174
- } else {
175
- // bukan nomor saya, abaikan
176
- return;
177
- }
178
- } else {
179
- // bukan private/grup chat dari nomor saya, abaikan
180
- return;
181
- }
182
-
183
- function reply(text) {
184
- socket.sendMessage(
185
- msg.key.remoteJid,
186
- { text: text },
187
- { quoted: msg }
188
- );
189
  }
190
 
191
- if (!msg.message) return;
192
-
193
- const msgType = Object.keys(msg.message)[0];
194
- const msgText =
195
- msgType === "conversation"
196
- ? msg.message.conversation
197
- : msgType === "extendedTextMessage"
198
- ? msg.message.extendedTextMessage.text
199
- : msgType === "imageMessage"
200
- ? msg.message.imageMessage.caption
201
- : "";
202
-
203
- if (!msgText.startsWith(".")) return;
204
-
205
- console.log(`Message Type: ${msgType}\nMessage Text: ${msgText}`);
206
-
207
- const command = msgText.split(" ")[0].slice(1);
208
-
209
- console.log(`Command: ${command}`);
210
- const id = msg.key.remoteJid;
211
-
212
- const UserText = msgText.slice(msgText.indexOf(' ') + 1);
213
-
214
- switch (command.toLowerCase()) {
215
-
216
- case "menu":
217
- async function bot_menu() {
218
- await socket.sendMessage(id, {
219
- text: BotInfo,
220
- contextInfo: {
221
- forwardingScore: 700,
222
- isForwarded: false,
223
- forwardedNewsletterMessageInfo: {
224
- newsletterJid: '',
225
- newsletterName: "Another",
226
- serverMessageId: -1
227
- },
228
- externalAdReply: {
229
- showAdAttribution: false,
230
- containsAutoReply: true,
231
- title: "Will you promise to spend the most time with me?♥",
232
- mediaType: 1,
233
- thumbnailUrl: "https://i.pinimg.com/564x/fb/de/2e/fbde2e5834e2e1a5adb9d7d9508d79ab.jpg",
234
- mediaUrl: "https://monikai.000webhostapp.com/",
235
- sourceUrl: "https://monikai.000webhostapp.com/"
236
- }
237
- }
238
- }, {
239
- quoted: msg
240
- });
241
- }
242
- bot_menu();
243
- break;
244
-
245
- case "link":
246
- reply("Successfully linked");
247
- break;
248
-
249
- case "del": case "hapus":
250
- if (!msg.message.extendedTextMessage) {
251
- return;
252
- }
253
-
254
- const delMsg = {
255
- id: msg.message.extendedTextMessage.contextInfo.stanzaId,
256
- remoteJid: msg.key.remoteJid,
257
- fromMe: true
258
- };
259
-
260
- socket.sendMessage(id, { delete: delMsg })
261
- .then(() => {})
262
- .catch(err => {
263
- reply("Gagal menghapus chat!");
264
- });
265
- break;
266
-
267
- //----------- AI ----------------------------------------------------------------------------------------------------------------------//
268
- case "monika":
269
- const reaction_case_monika = { react: { text: "❤️", key: msg.key } };
270
- socket.sendMessage(id, reaction_case_monika, { quoted: msg }).catch(err => console.error(err));
271
-
272
- async function getResponse() {
273
- try {
274
- const res = await fetch(`https://yuuki0125-monika-api.hf.space/AnotherAPI/${api_key}/GPT/Monika/${UserText}`);
275
- if (!res.ok) {
276
- throw new Error("Gagal fetch data");
277
- }
278
-
279
- const json = await res.json();
280
-
281
- if (!json.response) {
282
- throw new Error("Respon kosong");
283
- }
284
-
285
- return json.response;
286
-
287
- } catch (err) {
288
- console.error(err);
289
- }
290
- }
291
-
292
- getResponse().then(res => {
293
- socket.sendMessage(id, {
294
- text: res,
295
- contextInfo: {
296
- forwardingScore: 700,
297
- isForwarded: false,
298
- forwardedNewsletterMessageInfo: {
299
- newsletterJid: '',
300
- newsletterName: "Another",
301
- serverMessageId: -1
302
- },
303
- externalAdReply: {
304
- showAdAttribution: false,
305
- containsAutoReply: true,
306
- title: "Will you promise to spend the most time with me?♥",
307
- mediaType: 1,
308
- thumbnailUrl: "https://i.pinimg.com/564x/fb/de/2e/fbde2e5834e2e1a5adb9d7d9508d79ab.jpg",
309
- mediaUrl: "https://monikai.000webhostapp.com/",
310
- sourceUrl: "https://monikai.000webhostapp.com/"
311
- }
312
- }
313
- }, {
314
- quoted: msg
315
- });
316
- }).catch(err => {
317
- console.error(err);
318
- });
319
- break;
320
-
321
- case "noir":
322
- const reaction_case_noir = { react: { text: "♾️", key: msg.key } };
323
- socket.sendMessage(id, reaction_case_noir, { quoted: msg }).catch(err => console.error(err));
324
-
325
- async function getResponse2() {
326
- try {
327
- const res = await fetch(`https://yuuki0125-noir-api.hf.space/AnotherAPI/${api_key}/GPT/Noir/${UserText}`);
328
- if (!res.ok) {
329
- throw new Error("Gagal fetch data");
330
- }
331
-
332
- const json = await res.json();
333
-
334
- if (!json.response) {
335
- throw new Error("Respon kosong");
336
- }
337
-
338
- return json.response;
339
-
340
- } catch (err) {
341
- console.error(err);
342
- }
343
- }
344
-
345
- getResponse2().then(res => {
346
- socket.sendMessage(id, {
347
- text: res,
348
- contextInfo: {
349
- forwardingScore: 700,
350
- isForwarded: false,
351
- forwardedNewsletterMessageInfo: {
352
- newsletterJid: '',
353
- newsletterName: "Another",
354
- serverMessageId: -1
355
- },
356
- externalAdReply: {
357
- showAdAttribution: false,
358
- containsAutoReply: true,
359
- title: "Master, is Noir useful to you?",
360
- mediaType: 1,
361
- thumbnailUrl: "https://i.pinimg.com/564x/ca/b9/6e/cab96ec23af20fafbad9f0e33ee32e8d.jpg",
362
- mediaUrl: "https://monikai.000webhostapp.com/",
363
- sourceUrl: "https://monikai.000webhostapp.com/"
364
- }
365
- }
366
- }, {
367
- quoted: msg
368
- });
369
- }).catch(err => {
370
- console.error(err);
371
- });
372
- break;
373
-
374
- case "an":
375
- const reaction_case_2b_new = { react: { text: "♾️", key: msg.key } };
376
- socket.sendMessage(id, reaction_case_2b_new, { quoted: msg }).catch(err => console.error(err));
377
-
378
- async function characters_ai_new() {
379
- let res = await fetch(`https://yuuki0125-characters-api.hf.space/AnotherAPI/2B/new_chat/${api_key}/${UserText}`)
380
- if (!res.ok) throw 'Error fetching response';
381
- let json = await res.json();
382
- if (!json['2b']) throw 'Error!';
383
-
384
- const respon = json['2b'];
385
- socket.sendMessage(id, {
386
- text: respon,
387
- contextInfo: {
388
- forwardingScore: 700,
389
- isForwarded: false,
390
- forwardedNewsletterMessageInfo: {
391
- newsletterJid: '',
392
- newsletterName: "Another",
393
- serverMessageId: -1
394
- },
395
- externalAdReply: {
396
- showAdAttribution: false,
397
- containsAutoReply: true,
398
- title: "Glory to mankind",
399
- mediaType: 1,
400
- thumbnailUrl: "https://i.pinimg.com/564x/51/96/14/519614e68d7dd5c4cd5ca5610dc57fcd.jpg",
401
- mediaUrl: "https://monikai.000webhostapp.com/",
402
- sourceUrl: "https://monikai.000webhostapp.com/"
403
- }
404
- }
405
- }, {
406
- quoted: msg
407
- });
408
- }
409
- characters_ai_new()
410
- break;
411
-
412
- case "al":
413
- const reaction_case_2b_load = { react: { text: "♾️", key: msg.key } };
414
- socket.sendMessage(id, reaction_case_2b_load, { quoted: msg }).catch(err => console.error(err));
415
-
416
- async function characters_ai() {
417
- let res = await fetch(`https://yuuki0125-characters-api.hf.space/AnotherAPI/2B/chat/${api_key}/${UserText}`)
418
- if (!res.ok) throw 'Error fetching response';
419
- let json = await res.json();
420
- if (!json['2b']) throw 'Error!';
421
-
422
- const respon = json['2b'];
423
- socket.sendMessage(id, {
424
- text: respon,
425
- contextInfo: {
426
- forwardingScore: 700,
427
- isForwarded: false,
428
- forwardedNewsletterMessageInfo: {
429
- newsletterJid: '',
430
- newsletterName: "Another",
431
- serverMessageId: -1
432
- },
433
- externalAdReply: {
434
- showAdAttribution: false,
435
- containsAutoReply: true,
436
- title: "Glory to mankind",
437
- mediaType: 1,
438
- thumbnailUrl: "https://i.pinimg.com/564x/51/96/14/519614e68d7dd5c4cd5ca5610dc57fcd.jpg",
439
- mediaUrl: "https://monikai.000webhostapp.com/",
440
- sourceUrl: "https://monikai.000webhostapp.com/"
441
- }
442
- }
443
- }, {
444
- quoted: msg
445
- });
446
- }
447
- characters_ai()
448
- break;
449
-
450
- //----------- Downloader ----------------------------------------------------------------------------------------------------------------------//
451
- case 'ytmp3':
452
- const reaction_case_audio = { react: { text: "🎧", key: msg.key } };
453
- socket.sendMessage(id, reaction_case_audio, { quoted: msg }).catch(err => console.error(err));
454
- async function yt_download_mp3() {
455
- const youtube_url = UserText;
456
- const url_mp3 = `https://yuuki0125-yt-downloader-api.hf.space/AnotherAPI/${api_key}/downloader/YT/mp3/`;
457
-
458
- const params = { youtube_url };
459
-
460
- try {
461
- const response = await axios.post(url_mp3, null, { params, responseType: 'arraybuffer' });
462
-
463
- if (response.status === 200) {
464
-
465
- const dirPath = `${Media}`;
466
- if (!fs.existsSync(dirPath)) {
467
- fs.mkdirSync(dirPath, { recursive: true });
468
- }
469
-
470
- const audioPath = `${Media}/yt_audio.mp3`;
471
- fs.writeFileSync(audioPath, Buffer.from(response.data, 'binary'));
472
-
473
- const convertToOpus = async (inputFile, outputFile) => {
474
- const promise = new Promise((resolve, reject) => {
475
-
476
- ffmpeg(inputFile)
477
- .audioCodec('libopus')
478
- .audioFrequency(48000)
479
- .on('end', resolve)
480
- .on('error', reject)
481
- .saveToFile(outputFile, { createDirs: true });
482
-
483
- });
484
- await promise;
485
- };
486
- const inputFile = audioPath;
487
- const outputFile = `${Media}/yt_audio.opus`;
488
-
489
- await convertToOpus(inputFile, outputFile)
490
- .catch(err => console.log('Error: ' + err.message));
491
-
492
- const buffer = fs.readFileSync(outputFile);
493
- await socket.sendMessage(id, { audio: buffer, mimeType: "audio/mp3" }, { quoted: msg });
494
-
495
- } else {
496
- console.error(`Failed to download audio: ${response.status}`);
497
- }
498
- } catch (error) {
499
- console.error('Error:', error.message);
500
- }
501
- }
502
- yt_download_mp3();
503
- break;
504
-
505
- case 'ytmp4':
506
- const reaction_case_video = { react: { text: "▶️", key: msg.key } };
507
- socket.sendMessage(id, reaction_case_video, { quoted: msg }).catch(err => console.error(err));
508
- async function yt_downloader_mp4() {
509
- const youtube_url = UserText;
510
- const url_mp3 = `https://yuuki0125-yt-downloader-api.hf.space/AnotherAPI/${api_key}/downloader/YT/mp4/`;
511
-
512
- const params = { youtube_url };
513
-
514
- try {
515
- const response = await axios.post(url_mp3, null, { params, responseType: 'arraybuffer' });
516
-
517
- if (response.status === 200) {
518
-
519
- const dirPath = `${Media}`;
520
- if (!fs.existsSync(dirPath)) {
521
- fs.mkdirSync(dirPath, { recursive: true });
522
- }
523
-
524
- const videoPath = `${Media}/yt_video.mp4`;
525
- await fs.writeFileSync(videoPath, Buffer.from(response.data, 'binary'));
526
- socket.sendMessage(id, {video: fs.readFileSync(videoPath), mimeType: "video/mp4"}, { quoted: msg })
527
- .then(() => {
528
- deleteFilesInFolder(folderPath);
529
- })
530
- } else {
531
- console.error(`Failed to download audio: ${response.status}`);
532
- }
533
- } catch (error) {
534
- console.error('Error:', error.message);
535
- }
536
- }
537
- yt_downloader_mp4();
538
- break;
539
-
540
- case "pinterest":
541
- const reaction_case_pinterest = { react: { text: "✨", key: msg.key } };
542
- socket.sendMessage(id, reaction_case_pinterest, { quoted: msg }).catch(err => console.error(err));
543
- async function Pinterest_Downloader() {
544
- const Endpoint = 'https://yuuki0125-pinterest-downloader.hf.space';
545
-
546
- (async () => {
547
- try {
548
- const response = await fetch(`${Endpoint}/AnotherAPI/${api_key}/Pinterest/Downloader?url=${UserText}`);
549
- if (response.ok) {
550
- const data = await response.json();
551
- const media_type = data.type;
552
- const media_link = data.link;
553
-
554
- const dirPath = `${Media}`;
555
- if (!fs.existsSync(dirPath)) {
556
- fs.mkdirSync(dirPath, { recursive: true });
557
- }
558
- if(media_type === 'video') {
559
- const video_response = await fetch(media_link);
560
- const video_buffer = await video_response.buffer();
561
-
562
- fs.writeFileSync(`${dirPath}/video.mp4`, video_buffer);
563
- socket.sendMessage(
564
- id,
565
- {
566
- video: fs.readFileSync(`${dirPath}/video.mp4`),
567
- mimeType: "video/mp4",
568
- caption: media_link
569
- },
570
- { quoted: msg }
571
- )
572
- .then(() => {
573
- deleteFilesInFolder(folderPath);
574
- })
575
- } else {
576
- const image_response = await fetch(media_link);
577
- const image_buffer = await image_response.buffer();
578
- fs.writeFileSync(`${dirPath}/Pinterest.png`, image_buffer);
579
- await socket.sendMessage(id, { image: { url: `${dirPath}/Pinterest.png` }, mimeType: "image/png", caption: media_link }, { quoted: msg })
580
- .then(() => {
581
- deleteFilesInFolder(folderPath);
582
- })
583
- }
584
- } else {
585
- console.error(`Error: ${response.status}, ${await response.text()}`);
586
- }
587
- } catch (error) {
588
- console.error(`An error occurred: ${error.message}`);
589
- }
590
- })();
591
- }
592
- Pinterest_Downloader()
593
- break;
594
-
595
- case "fb":
596
- async function FB_Downloader() {
597
- const apiUrl = `https://yuuki0125-fb-downloder.hf.space/AnotherAPI/${api_key}/FB_Downloader/?url=${UserText}`;
598
-
599
- fetch(apiUrl)
600
- .then(res => res.json())
601
- .then(async data => {
602
- if(data.success) {
603
- const hdLink = data.links['Download High Quality'];
604
-
605
- const videoResponse = await fetch(hdLink);
606
- const videoBuffer = await videoResponse.buffer();
607
-
608
- const dirPath = `${Media}`;
609
- if (!fs.existsSync(dirPath)) {
610
- fs.mkdirSync(dirPath, { recursive: true });
611
- }
612
-
613
- fs.writeFile(`${Media}/FB_Downloader.mp4`, videoBuffer, () => {
614
- socket.sendMessage(
615
- id,
616
- {
617
- video: fs.readFileSync(`${Media}/FB_Downloader.mp4`),
618
- mimeType: "video/mp4",
619
- caption: data.title
620
- },
621
- { quoted: msg }
622
- )
623
- .then(() => {
624
- deleteFilesInFolder(folderPath);
625
- })
626
- });
627
-
628
- } else {
629
- console.log('Gagal mendapatkan link unduh');
630
- }
631
- })
632
- .catch(err => {
633
- console.log('Error:', err);
634
- });
635
- }
636
- FB_Downloader()
637
- break;
638
-
639
- //----------- Tools ----------------------------------------------------------------------------------------------------------------------//
640
- case "ti":
641
- const reaction_case_to_img = { react: { text: "✨", key: msg.key } };
642
- socket.sendMessage(id, reaction_case_to_img, { quoted: msg }).catch(err => console.error(err));
643
-
644
- async function stiker_to_img() {
645
- try {
646
- let mediaMessage;
647
- let isReplyToSticker = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.stickerMessage;
648
-
649
- if (isReplyToSticker) {
650
- mediaMessage = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.stickerMessage;
651
- } else {
652
- reply('Mohon balas stiker yang ingin dikonversi!');
653
- }
654
-
655
- const stream = await downloadContentFromMessage(mediaMessage, 'sticker');
656
-
657
- const dirPath = `${Media}`;
658
- if (!fs.existsSync(dirPath)) {
659
- fs.mkdirSync(dirPath, { recursive: true });
660
- }
661
-
662
- const filePath = `${dirPath}/sticker-${new Date().getTime()}`;
663
- const fileSavePath = `${filePath}.webp`;
664
- const imageOutputPath = `${filePath}.png`;
665
-
666
- const fileStream = fs.createWriteStream(fileSavePath);
667
-
668
- for await (const chunk of stream) {
669
- fileStream.write(chunk);
670
- }
671
-
672
- fileStream.end();
673
-
674
- fileStream.on('finish', async () => {
675
- sharp(fileSavePath)
676
- .toFormat('png')
677
- .toFile(imageOutputPath, (err) => {
678
- if (err) {
679
- console.log(chalk.red('Gagal mengonversi:'), err);
680
- reply('Maaf Master, terjadi kesalahan saat mengonversi.');
681
- return;
682
- }
683
- socket.sendMessage(id, { image: { url: imageOutputPath }, mimeType: "image/png" }, { quoted: msg })
684
- .then(() => {
685
- deleteFilesInFolder(folderPath);
686
- })
687
- .catch((sendErr) => {
688
- console.error('Gagal mengirim pesan:', sendErr);
689
- });
690
- });
691
- });
692
-
693
- } catch (e) {
694
- console.log('Gagal mengunduh atau memproses stiker:');
695
- reply('Maaf Master, terjadi kesalahan saat memproses.');
696
- }
697
- }
698
-
699
- stiker_to_img();
700
- break;
701
-
702
- case "s":
703
- const reaction_case_stiker = { react: { text: "✨", key: msg.key } };
704
- socket.sendMessage(id, reaction_case_stiker, { quoted: msg }).catch(err => console.error(err));
705
-
706
- async function stiker_maker() {
707
- try {
708
- let mediaMessage;
709
- if (msg.message.imageMessage) {
710
- mediaMessage = msg.message.imageMessage;
711
- } else if (msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage) {
712
- mediaMessage = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage;
713
- } else {
714
- reply('Silakan kirim atau reply gambar untuk membuat stiker.');
715
- }
716
-
717
- const stream = await downloadContentFromMessage(mediaMessage, 'image');
718
-
719
- const dirPath = `${Media}`; ;
720
- if (!fs.existsSync(dirPath)) {
721
- fs.mkdirSync(dirPath, { recursive: true });
722
- }
723
-
724
- const filePath = `${dirPath}/image-${new Date().getTime()}`;
725
- const fileSavePath = `${filePath}.jpg`;
726
- const stickerPath = `${filePath}-sticker.webp`;
727
-
728
- const fileStream = fs.createWriteStream(fileSavePath);
729
-
730
- for await (const chunk of stream) {
731
- fileStream.write(chunk);
732
- }
733
-
734
- fileStream.end();
735
-
736
- fileStream.on('finish', async () => {
737
- sharp(fileSavePath)
738
- .resize(512, 512, { fit: 'contain', background: { r: 0, g: 0, b: 0, alpha: 0 } })
739
- .toFormat('webp')
740
- .toFile(stickerPath, (err) => {
741
- if (err) {
742
- console.log('Gagal membuat stiker:');
743
- reply('Maaf Master, terjadi error saat membuat sticker.');
744
- return;
745
- }
746
- const stickerBuffer = fs.readFileSync(stickerPath);
747
- socket.sendMessage(id, { sticker: stickerBuffer }, { quoted: msg })
748
- .then(() => {
749
- deleteFilesInFolder(folderPath);
750
- })
751
- .catch((sendErr) => {
752
- console.error('Gagal mengirim pesan:', sendErr);
753
- });
754
- });
755
- });
756
-
757
- } catch (e) {
758
- console.log('Gagal mengunduh gambar:');
759
- reply('Master, terjadi kesalahan saat mengunduh gambar.');
760
- }
761
- }
762
-
763
- stiker_maker();
764
- break;
765
-
766
- case "upscale":
767
- const reaction_case_upscale = { react: { text: "✨", key: msg.key } };
768
- socket.sendMessage(id, reaction_case_upscale, { quoted: msg }).catch(err => console.error(err));
769
-
770
- async function upscaler() {
771
- try {
772
- let mediaMessage;
773
-
774
- if (msg.message.imageMessage) {
775
- mediaMessage = msg.message.imageMessage;
776
- } else if (msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage) {
777
- mediaMessage = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage;
778
- } else {
779
- reply('Mohon kirim/balas gambar yang ingin di-upscale!');
780
- }
781
-
782
- const stream = await downloadContentFromMessage(mediaMessage, 'image');
783
-
784
- const dirPath = `${Media}`;
785
- if (!fs.existsSync(dirPath)) {
786
- fs.mkdirSync(dirPath, { recursive: true });
787
- }
788
-
789
- const filePath = `${dirPath}/image-${new Date().getTime()}`;
790
- const nameIMG = `image-${new Date().getTime()}`;
791
- const fileSavePath = `${filePath}.jpg`;
792
-
793
- const fileStream = fs.createWriteStream(fileSavePath);
794
-
795
- for await (const chunk of stream) {
796
- fileStream.write(chunk);
797
- }
798
-
799
- fileStream.end();
800
-
801
- const FormData = require('form-data');
802
-
803
- const base_url = "https://beec-34-141-136-107.ngrok-free.app";
804
- const endpoint = "/super_resolution";
805
- const image_file_path = fileSavePath;
806
-
807
- fileStream.on('finish', async () => {
808
- try {
809
- const fileData = fs.readFileSync(image_file_path);
810
- const formData = new FormData();
811
- formData.append('file', Buffer.from(fileData), {
812
- filename: (`${nameIMG}.jpg`),
813
- contentType: 'image/jpeg'
814
- });
815
-
816
- const response = await fetch(`${base_url}${endpoint}`, {
817
- method: 'POST',
818
- body: formData
819
- });
820
-
821
- const Upscale = './tmp/images/sticker';
822
-
823
- if (response.status === 200) {
824
- const outputData = await response.buffer();
825
- fs.writeFileSync(Upscale, outputData);
826
- console.log("Berhasil");
827
- } else {
828
- console.log(`Failed. Status code: ${response.status}`);
829
- console.log(await response.text());
830
- }
831
-
832
- socket.sendMessage(id, { image: { url: Upscale }, mimeType: "image/png" }, { quoted: msg })
833
- .then(() => {
834
- deleteFilesInFolder(folderPath);
835
- })
836
- } catch (error) {
837
- reply('Maaf Master, terjadi kesalahan saat melakukan proses upscale');
838
- }
839
- });
840
-
841
- } catch (e) {
842
- reply('Master, terjadi kesalahan saat mengunduh gambar.');
843
- }
844
- }
845
-
846
- upscaler();
847
- break;
848
 
849
- case "view":
850
- const reaction_case_view = { react: { text: "", key: msg.key } };
851
- socket.sendMessage(id, reaction_case_view, { quoted: msg }).catch(err => console.error(err));
852
-
853
- async function viewOnce() {
854
- if (msg.message.extendedTextMessage) {
855
- const quotedMsg = msg.message.extendedTextMessage.contextInfo.quotedMessage;
856
- if (!quotedMsg?.viewOnceMessageV2) {
857
- return;
858
- }
859
-
860
- const viewOnce = quotedMsg.viewOnceMessageV2;
861
- const message = viewOnce.message;
862
-
863
- if (message.imageMessage) {
864
- // Image
865
- const imageMessage = message.imageMessage;
866
-
867
- const stream = await downloadContentFromMessage(imageMessage, 'image');
868
- let buffer = Buffer.from([]);
869
-
870
- for await (const chunk of stream) {
871
- buffer = Buffer.concat([buffer, chunk]);
872
- }
873
-
874
- const dirPath = `${Media}`;
875
- if (!fs.existsSync(dirPath)) {
876
- fs.mkdirSync(dirPath, { recursive: true });
877
- }
878
-
879
- fs.writeFileSync(`${dirPath}/gambar.png`, buffer);
880
-
881
- socket.sendMessage(id, { image: { url: `${dirPath}/gambar.png` }}, { quoted: msg });
882
-
883
- } else if (message.videoMessage) {
884
- // Video
885
- const videoMessage = message.videoMessage;
886
-
887
- const stream = await downloadContentFromMessage(videoMessage, 'video');
888
- let buffer = Buffer.from([]);
889
-
890
- for await (const chunk of stream) {
891
- buffer = Buffer.concat([buffer, chunk]);
892
- }
893
-
894
- const filePath = `${Media}/video.mp4`;
895
- fs.writeFileSync(filePath, buffer);
896
-
897
- socket.sendMessage(
898
- id,
899
- { video: { url: filePath }, fileName: 'video.mp4'},
900
- { quoted: msg }
901
- );
902
- }
903
-
904
- } else {
905
- reply("Chat ini bukan media view once");
906
- }
907
  }
908
-
909
- viewOnce();
910
- break;
911
 
912
- case "sc":
913
- const reaction_case_sauce = { react: { text: "✨", key: msg.key } };
914
- socket.sendMessage(id, reaction_case_sauce, { quoted: msg }).catch(err => console.error(err));
915
- async function sauce() {
916
- try {
917
- let mediaMessage;
918
- if (msg.message.imageMessage) {
919
- mediaMessage = msg.message.imageMessage;
920
- } else if (msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage) {
921
- mediaMessage = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage;
922
- } else {
923
- reply('Silakan kirim atau reply gambar untuk membuat stiker.');
924
- }
925
- const stream = await downloadContentFromMessage(mediaMessage, 'image');
926
- let buffer = Buffer.from([]);
927
-
928
- for await (const chunk of stream) {
929
- buffer = Buffer.concat([buffer, chunk]);
930
- }
931
-
932
- const dirPath = `${Media}`; ;
933
- if (!fs.existsSync(dirPath)) {
934
- fs.mkdirSync(dirPath, { recursive: true });
935
- }
936
- fs.writeFileSync(`${dirPath}/sauce.png`, buffer);
937
- const res = await fetch('https://api.trace.moe/search', {
938
- method: 'POST',
939
- body: fs.createReadStream(`${dirPath}/sauce.png`),
940
- headers: { 'Content-Type': 'image/jpeg' }
941
- });
942
-
943
- if (!res.ok) {
944
- throw new Error(`Error ${res.status}: ${res.statusText}`);
945
- }
946
-
947
- const data = await res.json();
948
- const topResult = data.result[0];
949
-
950
- let title = topResult.filename;
951
- title = title.replace(/\[.*?\] /g, '');
952
- title = title.replace(/ \(.*?\)/g, '');
953
- title = title.replace(/\.mp4$/g, '');
954
-
955
- const Episode = topResult.episode;
956
- const Similarity = parseInt(topResult.similarity.toFixed(2).replace('.', ''));
957
- const VideoLink = topResult.video;
958
- const video_path = `${dirPath}/sauce.mp4`
959
- const sauce_anime = `
960
- ╎❏ *Judul:* ${title}
961
- ╎❏ *Episode:* ${Episode}
962
- ╎❏ *Similarity:* ${Similarity}%
963
- `
964
- if (!fs.existsSync(dirPath)) {
965
- fs.mkdirSync(dirPath, {recursive: true});
966
- }
967
-
968
- await fetch(VideoLink)
969
- .then(res => res.buffer())
970
- .then(buffer => fs.writeFileSync(video_path, buffer))
971
- .catch(err => console.error(err));
972
-
973
- socket.sendMessage(
974
- id,
975
- {
976
- video: fs.readFileSync(video_path),
977
- mimeType: "video/mp4",
978
- caption: sauce_anime
979
- },
980
- { quoted: msg }
981
- )
982
- .then(() => {
983
- deleteFilesInFolder(folderPath);
984
- })
985
-
986
- } catch (err) {
987
- console.error(err);
988
- }
989
- }
990
- sauce();
991
- break;
992
 
993
- //----------- Search ----------------------------------------------------------------------------------------------------------------------//
994
- case "pinsc":
995
- const reaction_case_pinterest_search = { react: { text: "", key: msg.key } };
996
- socket.sendMessage(id, reaction_case_pinterest_search, { quoted: msg }).catch(err => console.error(err));
997
- async function pinterest_search_v2(search) {
998
- return new Promise(async(resolve, reject) => {
999
- axios.get('https://id.pinterest.com/search/pins/?autologin=true&q=' + search, {
1000
- headers: {
1001
- "cookie" : "_auth=1; _b=\"AVna7S1p7l1C5I9u0+nR3YzijpvXOPc6d09SyCzO+DcwpersQH36SmGiYfymBKhZcGg=\"; _pinterest_sess=TWc9PSZHamJOZ0JobUFiSEpSN3Z4a2NsMk9wZ3gxL1NSc2k2NkFLaUw5bVY5cXR5alZHR0gxY2h2MVZDZlNQalNpUUJFRVR5L3NlYy9JZkthekp3bHo5bXFuaFZzVHJFMnkrR3lTbm56U3YvQXBBTW96VUgzVUhuK1Z4VURGKzczUi9hNHdDeTJ5Y2pBTmxhc2owZ2hkSGlDemtUSnYvVXh5dDNkaDN3TjZCTk8ycTdHRHVsOFg2b2NQWCtpOWxqeDNjNkk3cS85MkhhSklSb0hwTnZvZVFyZmJEUllwbG9UVnpCYVNTRzZxOXNJcmduOVc4aURtM3NtRFo3STlmWjJvSjlWTU5ITzg0VUg1NGhOTEZzME9SNFNhVWJRWjRJK3pGMFA4Q3UvcHBnWHdaYXZpa2FUNkx6Z3RNQjEzTFJEOHZoaHRvazc1c1UrYlRuUmdKcDg3ZEY4cjNtZlBLRTRBZjNYK0lPTXZJTzQ5dU8ybDdVS015bWJKT0tjTWYyRlBzclpiamdsNmtpeUZnRjlwVGJXUmdOMXdTUkFHRWloVjBMR0JlTE5YcmhxVHdoNzFHbDZ0YmFHZ1VLQXU1QnpkM1FqUTNMTnhYb3VKeDVGbnhNSkdkNXFSMXQybjRGL3pyZXRLR0ZTc0xHZ0JvbTJCNnAzQzE0cW1WTndIK0trY05HV1gxS09NRktadnFCSDR2YzBoWmRiUGZiWXFQNjcwWmZhaDZQRm1UbzNxc21pV1p5WDlabm1UWGQzanc1SGlrZXB1bDVDWXQvUis3elN2SVFDbm1DSVE5Z0d4YW1sa2hsSkZJb1h0MTFpck5BdDR0d0lZOW1Pa2RDVzNySWpXWmUwOUFhQmFSVUpaOFQ3WlhOQldNMkExeDIvMjZHeXdnNjdMYWdiQUhUSEFBUlhUVTdBMThRRmh1ekJMYWZ2YTJkNlg0cmFCdnU2WEpwcXlPOVZYcGNhNkZDd051S3lGZmo0eHV0ZE42NW8xRm5aRWpoQnNKNnNlSGFad1MzOHNkdWtER0xQTFN5Z3lmRERsZnZWWE5CZEJneVRlMDd2VmNPMjloK0g5eCswZUVJTS9CRkFweHc5RUh6K1JocGN6clc1JmZtL3JhRE1sc0NMTFlpMVErRGtPcllvTGdldz0=; _ir=0"
1002
- }
1003
- }).then(async({ data }) => {
1004
- const x = cheerio.load(data);
1005
- const result = [];
1006
- const _output = [];
1007
- x('div > a').get().map(z => {
1008
- const _url = x(z).find('img').attr('src');
1009
- result.push(_url);
1010
- });
1011
- result.forEach(y => {
1012
- if (y == undefined) return;
1013
- _output.push(y.replace(/236/g,'736'));
1014
- });
1015
- _output.shift();
1016
- let dlUrl = _output[Math.floor(Math.random() * _output.length)];
1017
- resolve({
1018
- coder: 'Another',
1019
- result: {
1020
- img: dlUrl
1021
- },
1022
- warning: 'Nothing'
1023
- });
1024
- });
1025
-
1026
- });
1027
- }
1028
-
1029
- async function running_pinterest_search_v2(search) {
1030
- pinterest_search_v2(search).then(async (result) => {
1031
-
1032
- const url = result.result.img;
1033
-
1034
- const response = await axios({
1035
- url,
1036
- method: 'GET',
1037
- responseType: 'arraybuffer'
1038
- });
1039
 
1040
- socket.sendMessage(id, { image: response.data, mimeType: "image/png", caption: url }, { quoted: msg });
1041
-
1042
- }).catch(err => {
1043
- console.log(err);
1044
- });
1045
- }
1046
- running_pinterest_search_v2(UserText)
1047
- break;
1048
-
1049
- //----------- MISC ----------------------------------------------------------------------------------------------------------------------//
1050
- case "waifu":
1051
- const reaction_case_waifu = { react: { text: "✨", key: msg.key } };
1052
- socket.sendMessage(id, reaction_case_waifu, { quoted: msg }).catch(err => console.error(err));
1053
-
1054
- async function getWaifu() {
1055
- try {
1056
- const res = await fetch('https://api.waifu.pics/sfw/waifu');
1057
- const json = await res.json();
1058
-
1059
- if (!json.url) throw 'Error!';
1060
-
1061
- socket.sendMessage(
1062
- id,
1063
- { image: { url: json.url }, mimeType: "image/png" },
1064
- { quoted: msg }
1065
- );
1066
-
1067
- } catch (err) {
1068
- console.error(err);
1069
- }
1070
- }
1071
 
1072
- getWaifu().catch(err => console.error(err));
1073
- break;
1074
-
1075
- case "nsfw":
1076
- const reaction_case_nsfw = { react: { text: "✨", key: msg.key } };
1077
- socket.sendMessage(id, reaction_case_nsfw, { quoted: msg }).catch(err => console.error(err));
1078
-
1079
- async function getNfsw() {
1080
- try {
1081
- const res = await fetch('https://api.waifu.pics/nsfw/waifu');
1082
- const json = await res.json();
1083
-
1084
- if (!json.url) throw 'Error!';
1085
-
1086
- socket.sendMessage(
1087
- id,
1088
- { image: { url: json.url }, mimeType: "image/png" },
1089
- { quoted: msg }
1090
- );
1091
-
1092
- } catch (err) {
1093
- console.error(err);
1094
- }
1095
- }
1096
-
1097
- getNfsw().catch(err => console.error(err));
1098
- break;
1099
-
1100
- case "neko":
1101
- const reaction_case_neko = { react: { text: "✨", key: msg.key } };
1102
- socket.sendMessage(id, reaction_case_neko, { quoted: msg }).catch(err => console.error(err));
1103
-
1104
- async function getNeko() {
1105
- try {
1106
- const res = await fetch('https://api.waifu.pics/sfw/neko');
1107
- const json = await res.json();
1108
-
1109
- if (!json.url) throw 'Error!';
1110
-
1111
- socket.sendMessage(
1112
- id,
1113
- { image: { url: json.url }, mimeType: "image/png" },
1114
- { quoted: msg }
1115
- );
1116
-
1117
- } catch (err) {
1118
- console.error(err);
1119
- }
1120
- }
1121
-
1122
- getNeko().catch(err => console.error(err));
1123
- break;
1124
-
1125
- case "hneko":
1126
- const reaction_case_neko_nfsw = { react: { text: "✨", key: msg.key } };
1127
- socket.sendMessage(id, reaction_case_neko_nfsw, { quoted: msg }).catch(err => console.error(err));
1128
-
1129
- async function getNeko_nfsw() {
1130
- try {
1131
- const res = await fetch('https://api.waifu.pics/nsfw/neko');
1132
- const json = await res.json();
1133
-
1134
- if (!json.url) throw 'Error!';
1135
-
1136
- socket.sendMessage(
1137
- id,
1138
- { image: { url: json.url }, mimeType: "image/png" },
1139
- { quoted: msg }
1140
- );
1141
-
1142
- } catch (err) {
1143
- console.error(err);
1144
- }
1145
- }
1146
-
1147
- getNeko_nfsw().catch(err => console.error(err));
1148
- break;
1149
-
1150
- // -------------------------------------------------------------------------------------------------------//
1151
- case "randomanime":
1152
- const reaction_case_randomanime = { react: { text: "✨", key: msg.key } };
1153
- socket.sendMessage(id, reaction_case_randomanime, { quoted: msg }).catch(err => console.error(err));
1154
- async function random_anime() {
1155
- try {
1156
- let res = await fetch(`https://api.jikan.moe/v4/random/anime`);
1157
- if (!res.ok) throw new Error('Error fetching data');
1158
- let json = await res.json();
1159
- if (!json.data) throw new Error('Data not available');
1160
-
1161
- const image_anime = json.data.images.jpg.large_image_url;
1162
- const animeinfo = `✨️ *Title:* ${json.data.title}
1163
- 🎆️ *Episodes:* ${json.data.episodes}
1164
- 💌️ *Rating:* ${json.data.rated}
1165
- ❤️ *Score:* ${json.data.score}
1166
- 💚️ *Synopsis:* ${json.data.synopsis}`;
1167
-
1168
- socket.sendMessage(
1169
- id,
1170
- {
1171
- image: { url: image_anime },
1172
- caption: animeinfo,
1173
- mimeType: "image/png" },
1174
- { quoted: msg }
1175
- );
1176
- } catch (error) {
1177
- console.error(error);
1178
- }
1179
- }
1180
- random_anime();
1181
- break;
1182
-
1183
- case "randomchar":
1184
- const reaction_case_randomchar = { react: { text: "✨", key: msg.key } };
1185
- socket.sendMessage(id, reaction_case_randomchar, { quoted: msg }).catch(err => console.error(err));
1186
- async function random_char() {
1187
- let res = await fetch(`https://api.jikan.moe/v4/random/characters`)
1188
- if (!res.ok) throw eror
1189
- let json = await res.json()
1190
- if (!json.data) throw 'Error!'
1191
-
1192
- const animeinfo = `✨️ *Nama:* ${json.data.name}
1193
- 🎆️ *Kanji:* ${json.data.name_kanji}
1194
- ❤️ *Favorites:* ${json.data.favorites}
1195
- 💌️ *About:* ${json.data.about}`
1196
-
1197
- reply(animeinfo)
1198
- }
1199
- random_char()
1200
- break;
1201
- }
1202
- });
1203
- }
1204
-
1205
- connectToWhatsapp();
1206
-
1207
- app.get('/', (req, res) => {
1208
- console.log(req.url);
1209
- res.status(200).send('KEEP ONLINE');
1210
- });
1211
-
1212
- app.use((req, res) => {
1213
- console.log(req.url);
1214
- res.status(404).send("EndPoint not found");
1215
- });
1216
-
1217
- app.listen(PORT, () => {
1218
- console.log(`Server Listening on port ${PORT}`);
1219
- });
 
1
+ from fastapi import FastAPI
2
+ from characterai import PyCAI as AnotherAPI
3
+ import requests
4
+ import re
5
+ import json
6
+ import logging
7
+
8
+ app = FastAPI()
9
+
10
+ class VideoLinkExtractor:
11
+ """Class for extracting video links from HTML content."""
12
+
13
+ def __init__(self, html_content):
14
+ self.html_content = html_content
15
+
16
+ def clean_str(self, s):
17
+ """Cleans and returns a JSON-encoded string."""
18
+ try:
19
+ return json.loads(f'{{"text": "{s}"}}')['text']
20
+ except json.JSONDecodeError as e:
21
+ logging.error(f"Error decoding JSON: {e}")
22
+ return None
23
+
24
+ def get_link(self, regex):
25
+ """Extracts and returns link based on the provided regex."""
26
+ match = re.search(regex, self.html_content)
27
+ return self.clean_str(match.group(1)) if match else None
28
+
29
+ def get_title(self):
30
+ """Extracts and returns the title from HTML content."""
31
+ return self.get_link(r'<title>(.*?)<\/title>')
32
+
33
+ @app.get("/AnotherAPI/{api_key}/FB_Downloader/")
34
+ async def get_video_links(url: str, api_key: str,):
35
+ API = AnotherAPI(api_key)
36
+ API.chat.new_chat('csTC3hw0Fnj1Whnl0uV1Nb3_oYIillMQtdBH5NEl0Gs')
37
+ if not url:
38
+ return {"success": False, "message": "Please provide the URL"}
39
+
40
+ headers = {
41
+ 'sec-fetch-user': '?1',
42
+ 'sec-ch-ua-mobile': '?0',
43
+ 'sec-fetch-site': 'none',
44
+ 'sec-fetch-dest': 'document',
45
+ 'sec-fetch-mode': 'navigate',
46
+ 'cache-control': 'max-age=0',
47
+ 'authority': 'www.facebook.com',
48
+ 'upgrade-insecure-requests': '1',
49
+ 'accept-language': 'en-GB,en;q=0.9,tr-TR;q=0.8,tr;q=0.7,en-US;q=0.6',
50
+ 'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
51
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36',
52
+ 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
+ try:
56
+ r = requests.get(url, headers=headers)
57
+ r.raise_for_status()
58
+ extractor = VideoLinkExtractor(r.text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ data = {
61
+ "success": True,
62
+ "title": extractor.get_title(),
63
+ "links": {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
 
 
 
65
 
66
+ sd_link = extractor.get_link(r'browser_native_sd_url":"([^"]+)"')
67
+ if sd_link:
68
+ data["links"]["Download Low Quality"] = sd_link + "&dl=1"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ hd_link = extractor.get_link(r'browser_native_hd_url":"([^"]+)"')
71
+ if hd_link:
72
+ data["links"]["Download High Quality"] = hd_link + "&dl=1"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
+ return data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
+ except requests.RequestException as e:
77
+ logging.error(f"Request failed: {e}")
78
+ return {"success": False, "message": str(e)}