From d637443d2dbf40c79b53acdb9350b21cac428816 Mon Sep 17 00:00:00 2001 From: Sushi Date: Mon, 14 Mar 2022 08:21:25 -0600 Subject: [PATCH] ytdl implementation, fixed watch.vue --- NUXT/pages/watch.vue | 21 +++++++++++++++++---- NUXT/plugins/youtube.js | 13 +++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/NUXT/pages/watch.vue b/NUXT/pages/watch.vue index b23b38e..ee76e0e 100644 --- a/NUXT/pages/watch.vue +++ b/NUXT/pages/watch.vue @@ -1,7 +1,15 @@ @@ -14,9 +22,14 @@ export default { }, mounted() { this.$youtube.getVideo('wykQsTJElD4', (data) => { - const formats = data.formats; - console.log(data) - this.vidSrc = formats[formats.length-1].url; + this.vidTitle = data.title; + this.vidViews = data.views; + this.author = data.author; + this.uploaded = data.uploaded; + this.vidSrc = data.url; + this.visDescription = data.description; + this.likes = data.likes; + this.ryd = data.ryd; }) } } diff --git a/NUXT/plugins/youtube.js b/NUXT/plugins/youtube.js index 44c2990..305d9e5 100644 --- a/NUXT/plugins/youtube.js +++ b/NUXT/plugins/youtube.js @@ -122,18 +122,11 @@ const module = { Http.request({ method: 'GET', - url: 'https://youtube.com/watch', - //headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.7113.93 Safari/537.36' }, - params: { q: id } + url: 'https://vuetube-core.sushipython.repl.co/id/'+id }) .then((res) => { - //--- Get HTML Only ---// - let html = res.data; - logger("getVideo-html", html); - //--- Isolate The Script Containing Video Information ---// - html = html.split("var ytInitialPlayerResponse = ")[1].split("';")[0].split(";var meta = document.createElement('meta');")[0]; - //--- Parse JSON ---// - const videoData = JSON.parse(html).streamingData; + const videoData = res.data; + logger("videoData", videoData) callback(videoData); })