marriedtermiteblyi commited on
Commit
ed3c57a
·
verified ·
1 Parent(s): 6c1f07a

put notes/3713d2a0-698b-4f65-8c7f-6a128b141550.json

Browse files
notes/3713d2a0-698b-4f65-8c7f-6a128b141550.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "3713d2a0-698b-4f65-8c7f-6a128b141550",
3
+ "title": "autodown.js",
4
+ "content": "const { default: axios } = require(\"axios\");\n\nmodule.exports = class {\n static config = {\n name: 'autodown',\n aliases: [\"autodown\"],\n version: '1.1.1',\n role: 2,\n author: 'DongDev',\n info: 'Tự động tải xuống khi phát hiện liên kết',\n Category: 'Tiện ích',\n guides: '[]',\n cd: 2,\n hasPrefix: true,\n images: []\n };\n\n static urlify(text) {\n const urlRegex = /(https?:\\/\\/[^\\s]+)/gi;\n const matches = text.match(urlRegex);\n return matches || [];\n }\n\n static async onEvent({ api, event, msg }) {\n if (event.senderID == (global.botID || api.getCurrentUserID())) return;\n const send = (a, b, c, d) => api.sendMessage(a, b || event.threadID, c || null, d || event.messageID);\n const head = app => `[ AUTODOWN - ${app} ]\\n────────────────`;\n const urls = this.urlify(event.body);\n \n for (const str of urls) {\n if (/^https?:\\/\\/(?:vm\\.|vt\\.|v\\.|www\\.)?(?:tiktok)\\.com\\//.test(str)) {\n const res = await global.api.tiktok.downloadv3(str);\n if (res.attachments && res.attachments.length > 0) {\n let attachment = [];\n for (const attachmentItem of res.attachments) {\n if (attachmentItem.type === 'Video') {\n attachment.push(await global.tools.streamURL(attachmentItem.url, 'mp4'));\n } else if (attachmentItem.type === 'Photo') {\n attachment.push(await global.tools.streamURL(attachmentItem.url, 'jpg'));\n }\n }\n msg.reply({\n body: `${head('TIKTOK')}\\n⩺ Tiêu đề: ${res.message || \"\"}\\n⩺ Lượt xem: ${res.stats.views}\\n⩺ Lượt thích: ${res.stats.likes}\\n⩺ Bình luận: ${res.stats.comments}\\n⩺ Chia sẻ: ${res.stats.shares}\\n⩺ Lượt lưu: ${res.stats.collects}\\n⩺ Tác giả: ${res.author.name} (${res.author.username})\\n⩺ Âm nhạc: ${res.music.title}\\n⩺ Thời lượng: ${res.music.duration} giây\\n⩺ Thả cảm xúc '😆' để tải nhạc`,\n attachment\n }, (err, dataMsg) => {\n global.Seiko.onReaction.push({\n name: this.config.name,\n messageID: dataMsg.messageID,\n title: res.music.title || \"\",\n author: res.music.author,\n url: res.music.url,\n type: \"TIKTOK\"\n });\n });\n }\n } else if (/facebook\\.com|fb\\.watch/.test(str)) {\n const res = await global.api.facebook(encodeURIComponent(str));\n if (res.attachments && res.attachments.length > 0) {\n let attachment = [];\n if (res.queryStorieID) {\n const match = res.attachments.find(item => item.id == res.queryStorieID);\n if (match && match.type === 'Video') {\n const videoUrl = match.url.hd || match.url.sd;\n attachment.push(await global.tools.streamURL(videoUrl, 'mp4'));\n } else if (match && match.type === 'Photo') {\n attachment.push(await global.tools.streamURL(match.url, 'jpg'));\n }\n } else {\n for (const attachmentItem of res.attachments) {\n if (attachmentItem.type === 'Video') {\n const videoUrl = attachmentItem.url.hd || attachmentItem.url.sd;\n attachment.push(await global.tools.streamURL(videoUrl, 'mp4'));\n } else if (attachmentItem.type === 'Photo') {\n attachment.push(await global.tools.streamURL(attachmentItem.url, 'jpg'));\n }\n }\n }\n msg.reply({\n body: `${head('FACEBOOK')}\\n⩺ Tiêu đề: ${res.message || \"null\"}${res.like ? `\\n⩺ Lượt thích: ${res.like}` : ''}${res.comment ? `\\n⩺ Bình luận: ${res.comment}` : ''}${res.share ? `\\n⩺ Chia sẻ: ${res.share}` : ''}\\n⩺ Tác giả: ${res.author || \"unknown\"}`,\n attachment\n });\n }\n } else if (/youtube|youtu/.test(str)) {\n const res = await global.api.youtube.downloadv1(str);\n msg.reply({\n body: `${head('YOUTUBE')}\\n⩺ Title: ${res.title}\\n⩺ Thời lượng: ${res.duration}`,\n attachment: await global.tools.streamURL(res.url, 'mp4')\n });\n } else if (/instagram/.test(str)) {\n const res = await global.api.instagram.download(str);\n let attachments = [];\n if (res.attachments && res.attachments.length > 0) {\n for (const at of res.attachments) {\n if (at.type === 'Video') {\n attachments.push(await global.tools.streamURL(at.url, 'mp4'));\n } else if (at.type === 'Photo') {\n attachments.push(await global.tools.streamURL(at.url, 'jpg'));\n }\n }\n msg.reply({\n body: `${head('INSTAGRAM')}\\n⩺ Tiêu đề: ${res.message}\\n⩺ Tác giả: ${res.author}\\n⩺ Lượt thích: ${res.like}\\n⩺ Bình luận: ${res.comment}`,\n attachment: attachments\n });\n }\n } else if (/capcut/.test(str)) {\n const chosenVideo = await global.api.capcut.downloadv2(str);\n send({\n body: `${head('CAPCUT')}\\n⩺ Tiêu đề: ${chosenVideo.short_title} ${chosenVideo.title}\\n⩺ Tác giả: ${chosenVideo.author.name} (${chosenVideo.author.unique_id})\\n⩺ Số ảnh cần dùng: ${chosenVideo.fragment_count}\\n⩺ Lượt dùng mẫu: ${chosenVideo.usage_amount}\\n⩺ Lượt xem: ${chosenVideo.play_amount}\\n⩺ Lượt thích: ${chosenVideo.like_count}\\n⩺ Bình luận: ${chosenVideo.comment_count}\\n⩺ Lượt lưu: ${chosenVideo.favorite_count}`,\n attachment: await global.tools.streamURL(chosenVideo.video_url, 'mp4')\n });\n } else if (/soundcloud/.test(str)) {\n const result = await global.api.scldlv2(str);\n send({\n body: `${head('SOUNDCLOUD')}\\n⩺ Tiêu đề: ${result.title}\\n⩺ Tác giả: ${result.author.username}`,\n attachment: await global.tools.streamURL(result.url, 'mp3')\n });\n } else if (/threads\\.net\\//.test(str)) {\n const res = await global.api.threads.downloadv1(str);\n const data = res.results;\n const videos = data.filter(item => item.type === 'video');\n const photos = data.filter(item => item.type === 'image');\n \n const sendMedia = async (attachment) => {\n await send({\n body: `${head('THREADS')}\\n⩺ Tiêu đề: ${res.title}\\n⩺ Tác giả: ${res.user.username}`,\n attachment\n });\n };\n\n if (videos.length > 0) {\n const videoAttachments = await Promise.all(videos.map(item => global.tools.streamURL(item.url, 'mp4')));\n const filteredVideos = videoAttachments.filter(item => !!item);\n if (filteredVideos.length > 0) await sendMedia(filteredVideos);\n }\n\n if (photos.length > 0) {\n const photoAttachments = await Promise.all(photos.map(item => global.tools.streamURL(item.url, 'jpg')));\n const filteredPhotos = photoAttachments.filter(item => !!item);\n if (filteredPhotos.length > 0) await sendMedia(filteredPhotos);\n }\n } else if (/douyin/.test(str)) {\n const res = await global.api.downall.downloadv1(str);\n if (res.error) {\n send({ body: `${head('DOUYIN')}\\nCó lỗi khi tải dữ liệu: ${res.message}` });\n return;\n }\n \n if (res.attachments && res.attachments.length > 0) {\n let attachment = [];\n for (const media of res.attachments) {\n const stream = await global.tools.streamURL(media.url, media.extension || 'mp4');\n if (stream) attachment.push(stream);\n }\n \n if (attachment.length > 0) {\n await msg.reply({\n body: `${head('DOUYIN')}\\n⩺ Tiêu đề: ${res.title}${res.audio ? '\\n⩺ Thả cảm xúc \\'😆\\' để tải nhạc' : ''}`,\n attachment\n }, (error, info) => {\n if (res.audio) {\n global.Seiko.onReaction.push({\n type: \"DOUYIN\",\n name: this.config.name,\n messageID: info.messageID,\n author: event.senderID,\n title: res.title,\n url: res.audio\n });\n }\n });\n }\n }\n } else if (/zingmp3/.test(str)) {\n const res = await global.api.zingmp3.downloadv1(str);\n if (res.error) {\n send({ body: `${head('ZINGMP3')}\\n⩺ Lỗi: ${res.message}` });\n return;\n }\n \n const stream = await global.tools.streamURL(res.url, 'mp3');\n if (!stream) {\n send({ body: `${head('ZINGMP3')}\\n⩺ Lỗi: Không thể tải nhạc` });\n return;\n }\n \n send({\n body: `${head('ZINGMP3')}\\n⩺ Tiêu đề: ${res.title}\\n⩺ Ca sĩ: ${res.artist}\\n⩺ Chất lượng: ${res.quality}`,\n attachment: stream\n });\n } else if (/https?:\\/\\/(open\\.)?spotify\\.com\\/(track|album|playlist|artist|show|episode)\\/[a-zA-Z0-9]+/.test(str)) {\n try {\n const res = await global.api.downall.downloadv1(str);\n if (res.error) {\n send({ body: `${head('SPOTIFY')}\\nCó lỗi khi tải dữ liệu từ Spotify: ${res.message}` });\n return;\n }\n \n send({\n body: `${head('SPOTIFY')}\\n⩺ Title: ${res.title || 'Unknown'}\\n⩺ Duration: ${res.duration || 'Unknown'}\\n⩺ Artist: ${res.artist || 'Unknown'}`,\n attachment: await global.tools.streamURL(res.medias[0].url, 'mp3')\n });\n } catch (error) {\n console.error(\"Error fetching data from Spotify:\", error);\n send({ body: `${head('SPOTIFY')}\\nCó lỗi khi tải dữ liệu từ Spotify.` });\n }\n }\n }\n }\n\n static async onReaction({ api, event, onReaction, msg }) {\n const { type, url, title, author } = onReaction;\n if (type === \"TIKTOK\" || type === \"DOUYIN\" || type === \"YOUTUBE\") {\n msg.reply({\n body: `[ MUSIC ${type} ]\\n────────────────\\n⩺ Tiêu đề: ${title}`,\n attachment: await global.tools.streamURL(url, 'mp3')\n });\n }\n }\n\n static async onRun() {\n // Implementation for onRun if needed\n }\n}",
5
+ "language": "javascript",
6
+ "createdAt": 1758039822966,
7
+ "updatedAt": 1758039822966
8
+ }