This is just a temporary section for messing with the tool while it's still being worked on :)
- Open Watch Page
- Open Search Page
+ Watch Page
+ Search Page
diff --git a/NUXT/plugins/youtube.js b/NUXT/plugins/youtube.js
index 53263fe..27b20a7 100644
--- a/NUXT/plugins/youtube.js
+++ b/NUXT/plugins/youtube.js
@@ -29,6 +29,7 @@ const module = {
},
search(text, callback) {
+
Http.request({
method: 'GET',
url: 'https://youtube.com/results',
@@ -38,17 +39,38 @@ const module = {
//--- Get HTML Only ---//
let html = res.data;
//--- Isolate The Script Containing Video Information ---//
- html = html.split("var ytInitialData =")[1].split("")[0].slice(0, -1);
+ 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 & Get Results ---//
- let results = JSON.parse(html);
- results = results.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents;
- //--- Output ---//
- logger("search", results);
- callback(results);
+ //--- 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) {}
+ }
+
+
+
})
.catch((err) => {
logger("search", err);
diff --git a/scripts/build.bat b/scripts/build.bat
deleted file mode 100644
index 59c33c6..0000000
--- a/scripts/build.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-cd ../NUXT
-npm run generate
-cd ..
-npx cap sync
-npx cap open android
\ No newline at end of file
diff --git a/scripts/build.ps1 b/scripts/build.ps1
new file mode 100644
index 0000000..725e6ad
--- /dev/null
+++ b/scripts/build.ps1
@@ -0,0 +1 @@
+cd .\NUXT\; npm run generate; cd ..; npx cap sync
\ No newline at end of file
diff --git a/scripts/build.sh b/scripts/build.sh
index 59c33c6..e009dd6 100644
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -1,5 +1 @@
-cd ../NUXT
-npm run generate
-cd ..
-npx cap sync
-npx cap open android
\ No newline at end of file
+cd NUXT/; npm run generate; cd ..; npx cap sync
\ No newline at end of file