From 5128a6d5bc00c9c699ce1928edd16b30c948186a Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Sun, 29 Jan 2023 18:37:02 +0100 Subject: [PATCH] feat: easier way to download tiktok vids --- Dockerfile | 6 +----- events/djs/tiktok.ts | 13 +++++++------ package.json | 3 +-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8aa5b61..62f9e85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/events/djs/tiktok.ts b/events/djs/tiktok.ts index a0a3043..27cfb2d 100644 --- a/events/djs/tiktok.ts +++ b/events/djs/tiktok.ts @@ -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('❌') diff --git a/package.json b/package.json index 0867084..efee891 100644 --- a/package.json +++ b/package.json @@ -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",