diff --git a/NUXT/pages/search.vue b/NUXT/pages/search.vue index 8c9b42d..1ae4e4e 100644 --- a/NUXT/pages/search.vue +++ b/NUXT/pages/search.vue @@ -10,7 +10,7 @@ - +
diff --git a/NUXT/pages/watch.vue b/NUXT/pages/watch.vue index 92ee302..460a180 100644 --- a/NUXT/pages/watch.vue +++ b/NUXT/pages/watch.vue @@ -1,6 +1,8 @@ @@ -8,8 +10,16 @@ export default { data() { return { - vidSrc: "https://api.celeste.photos/squish.mp4" + id: "" } + }, + fetch() { + this.id = this.$route.query.v; + }, + mounted() { + new YouTubeToHtml5({ + withAudio: true + }); } } diff --git a/NUXT/plugins/youtube.js b/NUXT/plugins/youtube.js index e950294..15ae392 100644 --- a/NUXT/plugins/youtube.js +++ b/NUXT/plugins/youtube.js @@ -11,6 +11,38 @@ function logger(func, data, isError=false) { }) } +//--- Youtube Base Parser ---// +function youtubeParse(html, callback) { + //--- Replace Encoded Characters ---/// + html = html.replace(/\\x([0-9A-F]{2})/ig, (...items) => { return String.fromCharCode(parseInt(items[1], 16)); }); + //--- Properly Format JSON ---// + html = html.replaceAll("\\\\\"", ""); + //--- Parse JSON ---// + html = JSON.parse(html); + + //--- Get Results ---// ( Thanks To appit-online On Github ) -> https://github.com/appit-online/youtube-search/blob/master/src/lib/search.ts + let results; + if (html && html.contents && html.contents.sectionListRenderer && html.contents.sectionListRenderer.contents + && html.contents.sectionListRenderer.contents.length > 0 + && html.contents.sectionListRenderer.contents[0].itemSectionRenderer + && html.contents.sectionListRenderer.contents[0].itemSectionRenderer.contents.length > 0) { + results = html.contents.sectionListRenderer.contents[0].itemSectionRenderer.contents; + logger("search", results); + callback(results); + } else { + try { + results = JSON.parse(html.split('{"itemSectionRenderer":{"contents":')[html.split('{"itemSectionRenderer":{"contents":').length - 1].split(',"continuations":[{')[0]); + logger("search", results); + callback(results); + } catch (e) {} + try { + results = JSON.parse(html.split('{"itemSectionRenderer":')[html.split('{"itemSectionRenderer":').length - 1].split('},{"continuationItemRenderer":{')[0]).contents; + logger("search", results); + callback(results); + } catch(e) {} + } +} + //--- Search Main Function ---// function youtubeSearch(text, callback) { Http.request({ @@ -23,34 +55,10 @@ function youtubeSearch(text, callback) { let html = res.data; //--- Isolate The Script Containing Video Information ---// html = html.split("var ytInitialData = '")[1].split("';")[0]; - //--- Replace Encoded Characters ---/// - html = html.replace(/\\x([0-9A-F]{2})/ig, (...items) => { return String.fromCharCode(parseInt(items[1], 16)); }); - //--- Properly Format JSON ---// - html = html.replaceAll("\\\\\"", ""); - //--- Parse JSON ---// - html = JSON.parse(html); - - //--- Get Results ---// ( Thanks To appit-online On Github ) -> https://github.com/appit-online/youtube-search/blob/master/src/lib/search.ts - let results; - if (html && html.contents && html.contents.sectionListRenderer && html.contents.sectionListRenderer.contents - && html.contents.sectionListRenderer.contents.length > 0 - && html.contents.sectionListRenderer.contents[0].itemSectionRenderer - && html.contents.sectionListRenderer.contents[0].itemSectionRenderer.contents.length > 0) { - results = html.contents.sectionListRenderer.contents[0].itemSectionRenderer.contents; - logger("search", results); - callback(results); - } else { - try { - results = JSON.parse(html.split('{"itemSectionRenderer":{"contents":')[html.split('{"itemSectionRenderer":{"contents":').length - 1].split(',"continuations":[{')[0]); - logger("search", results); - callback(results); - } catch (e) {} - try { - results = JSON.parse(html.split('{"itemSectionRenderer":')[html.split('{"itemSectionRenderer":').length - 1].split('},{"continuationItemRenderer":{')[0]).contents; - logger("search", results); - callback(results); - } catch(e) {} - } + + youtubeParse(html, (data) => { + callback(data); + }) diff --git a/android/app/capacitor.build.gradle b/android/app/capacitor.build.gradle index 05542b0..7087534 100644 --- a/android/app/capacitor.build.gradle +++ b/android/app/capacitor.build.gradle @@ -12,6 +12,7 @@ dependencies { implementation project(':capacitor-community-http') implementation project(':capacitor-app') implementation project(':capacitor-browser') + implementation project(':capacitor-device') } diff --git a/android/app/src/main/assets/capacitor.plugins.json b/android/app/src/main/assets/capacitor.plugins.json index be508b6..11aedcb 100644 --- a/android/app/src/main/assets/capacitor.plugins.json +++ b/android/app/src/main/assets/capacitor.plugins.json @@ -10,5 +10,9 @@ { "pkg": "@capacitor/browser", "classpath": "com.capacitorjs.plugins.browser.BrowserPlugin" + }, + { + "pkg": "@capacitor/device", + "classpath": "com.capacitorjs.plugins.device.DevicePlugin" } ] diff --git a/android/capacitor.settings.gradle b/android/capacitor.settings.gradle index 636677d..27e5ed6 100644 --- a/android/capacitor.settings.gradle +++ b/android/capacitor.settings.gradle @@ -10,3 +10,6 @@ project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/ include ':capacitor-browser' project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/browser/android') + +include ':capacitor-device' +project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android') diff --git a/ios/App/Podfile b/ios/App/Podfile index 91c052f..a2e8777 100644 --- a/ios/App/Podfile +++ b/ios/App/Podfile @@ -12,6 +12,7 @@ def capacitor_pods pod 'CapacitorCommunityHttp', :path => '..\..\node_modules\@capacitor-community\http' pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app' pod 'CapacitorBrowser', :path => '..\..\node_modules\@capacitor\browser' + pod 'CapacitorDevice', :path => '..\..\node_modules\@capacitor\device' end target 'App' do