feat: easier way to download tiktok vids

This commit is contained in:
2023-01-29 18:37:02 +01:00
parent 4c27bca699
commit 5128a6d5bc
3 changed files with 9 additions and 13 deletions

View File

@@ -1,11 +1,7 @@
FROM node:lts
FROM node:lts-alpine
WORKDIR /app
RUN apt update && apt install chromium -y
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
COPY package.json ./
RUN npm i

View File

@@ -1,6 +1,5 @@
import { EventType, eventModule } from "@sern/handler";
import { Client, Message } from "discord.js";
import tiktok from 'tiktok-scraper-ts'
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, Client, Message } from "discord.js";
import axios from 'axios'
export default eventModule({
@@ -20,12 +19,14 @@ export default eventModule({
link = message.content.substring(index, endIndex);
}
const scrap = await tiktok.fetchVideo(link) as tiktok.Video
const shorten = await axios.get(`https://cutt.ly/api/api.php?key=${process.env.CUTTLY}&short=${scrap.playURL}`).then(res => res.data)
const scrap = await axios.get(`https://www.tikwm.com/api/?url=${link}`).then(res => res.data)
const shorten = await axios.get(`http://chilp.it/api.php?url=${scrap.data.play}`).then(res => res.data)
const audio = await axios.get(scrap.data.music, { responseType: 'arraybuffer' }).then(res => res.data)
const audioAttachment = new AttachmentBuilder(audio, { name: 'audio.mp3' })
await message.reply({
content: `Ok, tengo el enlace al vídeo: ${shorten.url.shortLink}`
content: `Vídeo: ${shorten}`,
files: [audioAttachment]
})
} catch {
message.react('❌')

View File

@@ -20,8 +20,7 @@
"axios": "^0.27.2",
"discord.js": "^14.2.0",
"dotenv": "^16.0.3",
"mongoose": "^6.7.2",
"tiktok-scraper-ts": "^1.4.1"
"mongoose": "^6.7.2"
},
"devDependencies": {
"@types/node": "^17.0.25",