From 748ae006513f9c0c58bb20eafa0d416b5226109a Mon Sep 17 00:00:00 2001 From: Kenny <27463495+Frontesque@users.noreply.github.com> Date: Mon, 14 Mar 2022 10:56:22 -0400 Subject: [PATCH] possibly make ytdl work? --- NUXT/plugins/youtube.js | 22 ++++++---------------- package.json | 3 ++- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/NUXT/plugins/youtube.js b/NUXT/plugins/youtube.js index 305d9e5..8095401 100644 --- a/NUXT/plugins/youtube.js +++ b/NUXT/plugins/youtube.js @@ -1,5 +1,6 @@ //--- Modules/Imports ---// import { Http } from '@capacitor-community/http'; +const ytdl = require('ytdl-core'); //--- Logger Function ---// function logger(func, data, isError=false) { @@ -55,7 +56,7 @@ function youtubeSearch(text, callback) { let html = res.data; //--- Isolate The Script Containing Video Information ---// html = html.split("var ytInitialData = '")[1].split("';")[0]; - + youtubeParse(html, (data) => { callback(data); }) @@ -118,22 +119,11 @@ const module = { }, - getVideo(id, callback) { + async getVideo(id, callback) { - Http.request({ - method: 'GET', - url: 'https://vuetube-core.sushipython.repl.co/id/'+id - }) - .then((res) => { - const videoData = res.data; - logger("videoData", videoData) - callback(videoData); - - }) - .catch((err) => { - logger("getVideo", err, true); - callback(err); - }); + const vidInfo = await ytdl.getInfo(id); + logger("getVideo", vidInfo) + callback(vidInfo); } diff --git a/package.json b/package.json index cacc6ce..e021215 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@capacitor/browser": "^1.0.7", "@capacitor/cli": "^3.4.0", "@capacitor/core": "^3.4.0", - "@capacitor/device": "^1.1.2" + "@capacitor/device": "^1.1.2", + "ytdl-core": "^4.11.0" } }