0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-26 21:23:02 +00:00

Merge pull request #103 from Frontesque/pr-branch

return youtube dislike, innertube fixes, html scraping
This commit is contained in:
Kenny 2022-03-19 14:11:28 -04:00 committed by GitHub
commit 7eef6918d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,8 +120,49 @@ const searchModule = {
},
getVideo(id) {
return id;
getRemainingVideoInfo(id, callback) {
String.prototype.decodeEscapeSequence = function() {
return this.replace(/\\x([0-9A-Fa-f]{2})/g, function() {
return String.fromCharCode(parseInt(arguments[1], 16));
});
};
Http.request({
method: 'GET',
url: `${constants.URLS.YT_URL}/watch`,
params: { v: id }
})
.then((res) => {
let dataUpdated = res.data.decodeEscapeSequence()
let likes = dataUpdated.split(`"defaultIcon":{"iconType":"LIKE"},"defaultText":{"runs":[{"text":"`)[1].split(`"}],"accessibility":`)[0]
let uploadDate = dataUpdated.split(`"uploadDate":"`)[1].split(`}},"trackingParams":"`)[0].slice(0, -2);
let data = {
"likes": likes,
"uploadDate": uploadDate
}
logger("vidData", data)
callback(data)
})
.catch((err) => {
logger("codeRun", err, true);
callback(err);
});
},
getReturnYoutubeDislike(id, callback) {
Http.request({
method: 'GET',
url: `https://returnyoutubedislikeapi.com/votes`,
params: { videoId: id }
})
.then((res) => {
logger("rydData", res.data)
callback(res.data)
})
.catch((err) => {
logger("codeRun", err, true);
callback(err);
});
}
}
@ -142,7 +183,7 @@ const recommendationModule = {
},
async getVid(id) {
return InnertubeAPI.getVidInfoAsync(id).data;
return InnertubeAPI.getVidInfoAsync(id);
},
async recommend() {
@ -157,4 +198,4 @@ export default ({ app }, inject) => {
inject('youtube', {...searchModule, ...recommendationModule, })
inject("logger", logger)
}
logger("Initialize", "Program Started");
logger("Initialize", "Program Started");