mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-22 19:25:16 +00:00
feat: test for youtube recommendation change after click on video
This commit is contained in:
parent
c540930135
commit
fba7caef4c
5 changed files with 28 additions and 11 deletions
|
@ -160,6 +160,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$youtube.saveApiStats("detailpage", this.$route.query.v, "streamingstats")
|
||||||
this.getVideo();
|
this.getVideo();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -6,6 +6,7 @@ const url = {
|
||||||
YT_MUSIC_URL: "https://music.youtube.com",
|
YT_MUSIC_URL: "https://music.youtube.com",
|
||||||
YT_BASE_API: "https://www.youtube.com/youtubei/v1",
|
YT_BASE_API: "https://www.youtube.com/youtubei/v1",
|
||||||
YT_SUGGESTIONS: "https://suggestqueries.google.com/complete",
|
YT_SUGGESTIONS: "https://suggestqueries.google.com/complete",
|
||||||
|
YT_API_STATS: "https://www.youtube.com/api/stats/atr",
|
||||||
VT_GITHUB: "https://api.github.com/repos/Frontesque/VueTube",
|
VT_GITHUB: "https://api.github.com/repos/Frontesque/VueTube",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,23 @@ class Innertube {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WARNING: This is tracking the user's activity, but is required for recommendations to properly work
|
||||||
|
async apiStats(currentPageType, id, event) {
|
||||||
|
const params = {
|
||||||
|
key: this.key,
|
||||||
|
el: currentPageType,
|
||||||
|
ns: "yt",
|
||||||
|
docid: id,
|
||||||
|
event: event,
|
||||||
|
feature: "g-high-rec",
|
||||||
|
c: this.context.client.clientName,
|
||||||
|
volume: 100,
|
||||||
|
cver: this.context.client.clientVersion,
|
||||||
|
hl: this.context.client.hl,
|
||||||
|
};
|
||||||
|
await Http.post({ url: constants.URLS.YT_API_STATS, params: params });
|
||||||
|
}
|
||||||
|
|
||||||
// Static methods
|
// Static methods
|
||||||
|
|
||||||
static getThumbnail(id, resolution) {
|
static getThumbnail(id, resolution) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Innertube from "./innertube";
|
||||||
import constants from "./constants";
|
import constants from "./constants";
|
||||||
import rendererUtils from "./renderers";
|
import rendererUtils from "./renderers";
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
|
import iconv from "iconv-lite";
|
||||||
|
|
||||||
//--- Logger Function ---//
|
//--- Logger Function ---//
|
||||||
function logger(func, data, isError = false) {
|
function logger(func, data, isError = false) {
|
||||||
|
@ -19,15 +20,7 @@ function getEncoding(contentType) {
|
||||||
const re = /charset=([^()<>@,;:\"/[\]?.=\s]*)/i;
|
const re = /charset=([^()<>@,;:\"/[\]?.=\s]*)/i;
|
||||||
const content = re.exec(contentType);
|
const content = re.exec(contentType);
|
||||||
console.log(content);
|
console.log(content);
|
||||||
if (!content || content[1].toLowerCase() == "utf-8") {
|
return content[1].toLowerCase();
|
||||||
return "utf8";
|
|
||||||
}
|
|
||||||
if (content[1].toLowerCase() == "iso-8859-1") {
|
|
||||||
return "latin1";
|
|
||||||
}
|
|
||||||
if (content[1].toLowerCase() == "utf16le") {
|
|
||||||
return "utf16le";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchModule = {
|
const searchModule = {
|
||||||
|
@ -45,7 +38,7 @@ const searchModule = {
|
||||||
// make a new buffer object from res.data
|
// make a new buffer object from res.data
|
||||||
const buffer = Buffer.from(res.data, "base64");
|
const buffer = Buffer.from(res.data, "base64");
|
||||||
// convert res.data from iso-8859-1 to utf-8
|
// convert res.data from iso-8859-1 to utf-8
|
||||||
const data = buffer.toString(getEncoding(contentType));
|
const data = iconv.decode(buffer, getEncoding(contentType));
|
||||||
logger(constants.LOGGER_NAMES.autoComplete, data);
|
logger(constants.LOGGER_NAMES.autoComplete, data);
|
||||||
callback(data);
|
callback(data);
|
||||||
})
|
})
|
||||||
|
@ -137,6 +130,10 @@ const innertubeModule = {
|
||||||
logger(constants.LOGGER_NAMES.search, err, true);
|
logger(constants.LOGGER_NAMES.search, err, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async saveApiStats(currentPageType, id, event) {
|
||||||
|
await InnertubeAPI.apiStats(currentPageType, id, event);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
//--- Start ---//
|
//--- Start ---//
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"@capacitor/share": "^1.1.2",
|
"@capacitor/share": "^1.1.2",
|
||||||
"@capacitor/splash-screen": "^1.2.2",
|
"@capacitor/splash-screen": "^1.2.2",
|
||||||
"@capacitor/status-bar": "^1.0.8",
|
"@capacitor/status-bar": "^1.0.8",
|
||||||
"@hugotomazi/capacitor-navigation-bar": "^1.1.1"
|
"@hugotomazi/capacitor-navigation-bar": "^1.1.1",
|
||||||
|
"iconv-lite": "^0.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue