Added raw file youtube support as holdover until invidious embed is

viable. This does not help with region locking, but at least allows
age restricted videos with no sign in, doesnt run any google scripts,
and does not run ads.
This commit is contained in:
rainbownapkin 2022-07-14 01:54:06 +00:00
parent 5535917f08
commit 3f653c4893
9 changed files with 122 additions and 57 deletions

View file

@ -1238,7 +1238,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
}
/* Lead-in time of 3 seconds to allow clients to buffer */
time = time || (media.seconds > 0 ? -3 : 0);
time = time || (media.seconds > 0 ? (media.type == "yt" ? -6 : -3) : 0); //if its a yt vid make it 6 for the link pull
media.paused = time < 0;
media.currentTime = time;
@ -1258,8 +1258,16 @@ PlaylistModule.prototype.startPlayback = function (time) {
if (!self.current || !self.current.media) {
return;
}
if(self.current.media.type == "yt"){//if its yt
InfoGetter.getYTRaw(self.current.media.id,function(url){//get raw link from invidious api
self.current.media.meta.rawLink = url;//set to meta
self.sendChangeMedia(self.channel.users);//fuggin SEND IT
});
self.sendChangeMedia(self.channel.users);
}else{
self.sendChangeMedia(self.channel.users);
}
self.channel.notifyModules("onMediaChange", [self.current.media]);
/* Only start the timer if the media item is not live, i.e. has a duration */

View file

@ -594,5 +594,26 @@ module.exports = {
} else {
callback("Unknown media type '" + type + "'", null);
}
}
},
getYTRaw: function (id, cb){
var options = {
host: Config.get("invidious-source"),
port: 443,
path: "/api/v1/videos/" + id,
method: "GET",
timeout: 1000
};
urlRetrieve(https, options, function (status, data) {
if(status !== 200) {
console.log("Invidious HTTPS error code: " + status);
}
var vid = JSON.parse(data);
if(vid.formatStreams[0] != null){//TEMPORARY FOR FRONTEND DEV PURPOSES, PULL LINK AND SET AGAIN WHEN VIDEO QUEUED(shit expires)
cb(vid.formatStreams[vid.formatStreams.length - 1].url);
}
});
}
};

View file

@ -41,7 +41,8 @@ Media.prototype = {
embed: this.meta.embed,
gdrive_subtitles: this.meta.gdrive_subtitles,
textTracks: this.meta.textTracks,
mixer: this.meta.mixer
mixer: this.meta.mixer,
rawLink: this.meta.rawLink
}
};