Youtube videos now refresh metadata 10 seconds before playback starts.

This commit is contained in:
rainbow napkin 2025-05-06 21:13:54 -04:00
parent a71f1d6cc0
commit 60cd21d938
4 changed files with 62 additions and 5 deletions

View file

@ -38,6 +38,22 @@ module.exports.yankMedia = async function(url, title){
}
}
module.exports.refreshRawLink = async function(mediaObj){
switch(mediaObj.type){
case 'yt':
//Re-fetch media metadata
metadata = await ytdlpUtil.fetchYoutubeVideoMetadata(mediaObj.id);
//Refresh media rawlink from metadata
mediaObj.rawLink = metadata[0].rawLink;
//return media object
return mediaObj;
}
//Return null to tell the calling function there is no refresh required for this media type
return null;
}
//I'd be lying if this didn't take at least some inspiration/regex patterns from extractQueryParam() in cytube/forest's browser-side 'util.js'
//Still this has some improvements like url pre-checks and the fact that it's handled serverside, recuing possibility of bad requests.
//Some of the regex expressions for certain services have also been improved, such as youtube, and the fore.st-unique archive.org