mirror of
https://github.com/VueTubeApp/VueTube
synced 2025-01-03 14:11:08 +00:00
Fix search tool & Update build scripts
This commit is contained in:
parent
4961838f50
commit
3b91ee4155
5 changed files with 33 additions and 19 deletions
|
@ -28,8 +28,8 @@
|
||||||
<v-card-title>Debug</v-card-title>
|
<v-card-title>Debug</v-card-title>
|
||||||
<section>
|
<section>
|
||||||
<div style="color: #999;">This is just a temporary section for messing with the tool while it's still being worked on :)</div>
|
<div style="color: #999;">This is just a temporary section for messing with the tool while it's still being worked on :)</div>
|
||||||
<v-btn to="/watch">Open Watch Page</v-btn>
|
<v-btn to="/watch">Watch Page</v-btn>
|
||||||
<v-btn to="/search">Open Search Page</v-btn>
|
<v-btn to="/search">Search Page</v-btn>
|
||||||
</section>
|
</section>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ const module = {
|
||||||
},
|
},
|
||||||
|
|
||||||
search(text, callback) {
|
search(text, callback) {
|
||||||
|
|
||||||
Http.request({
|
Http.request({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: 'https://youtube.com/results',
|
url: 'https://youtube.com/results',
|
||||||
|
@ -38,17 +39,38 @@ const module = {
|
||||||
//--- Get HTML Only ---//
|
//--- Get HTML Only ---//
|
||||||
let html = res.data;
|
let html = res.data;
|
||||||
//--- Isolate The Script Containing Video Information ---//
|
//--- Isolate The Script Containing Video Information ---//
|
||||||
html = html.split("var ytInitialData =")[1].split("</script>")[0].slice(0, -1);
|
html = html.split("var ytInitialData = '")[1].split("';</script>")[0];
|
||||||
//--- Replace Encoded Characters ---///
|
//--- Replace Encoded Characters ---///
|
||||||
html = html.replace(/\\x([0-9A-F]{2})/ig, (...items) => { return String.fromCharCode(parseInt(items[1], 16)); });
|
html = html.replace(/\\x([0-9A-F]{2})/ig, (...items) => { return String.fromCharCode(parseInt(items[1], 16)); });
|
||||||
//--- Properly Format JSON ---//
|
//--- Properly Format JSON ---//
|
||||||
html = html.replaceAll("\\\\\"", "");
|
html = html.replaceAll("\\\\\"", "");
|
||||||
//--- Parse JSON & Get Results ---//
|
//--- Parse JSON ---//
|
||||||
let results = JSON.parse(html);
|
html = JSON.parse(html);
|
||||||
results = results.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents;
|
|
||||||
//--- Output ---//
|
//--- Get Results ---// ( Thanks To appit-online On Github ) -> https://github.com/appit-online/youtube-search/blob/master/src/lib/search.ts
|
||||||
logger("search", results);
|
let results;
|
||||||
callback(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) => {
|
.catch((err) => {
|
||||||
logger("search", err);
|
logger("search", err);
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
cd ../NUXT
|
|
||||||
npm run generate
|
|
||||||
cd ..
|
|
||||||
npx cap sync
|
|
||||||
npx cap open android
|
|
1
scripts/build.ps1
Normal file
1
scripts/build.ps1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cd .\NUXT\; npm run generate; cd ..; npx cap sync
|
|
@ -1,5 +1 @@
|
||||||
cd ../NUXT
|
cd NUXT/; npm run generate; cd ..; npx cap sync
|
||||||
npm run generate
|
|
||||||
cd ..
|
|
||||||
npx cap sync
|
|
||||||
npx cap open android
|
|
Loading…
Reference in a new issue