queue refreshes raw link for items starting in less than 10 seconds, rawRefresh only refreshes expired links.
This commit is contained in:
parent
60cd21d938
commit
2a3740dece
3 changed files with 36 additions and 12 deletions
|
|
@ -15,7 +15,6 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//Node Imports
|
||||
const url = require("node:url");
|
||||
const validator = require('validator');
|
||||
|
||||
//Local Imports
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const url = require("node:url");
|
||||
const validator = require('validator');//No express here, so regular validator it is!
|
||||
|
||||
//local import
|
||||
|
|
@ -41,6 +42,16 @@ module.exports.yankMedia = async function(url, title){
|
|||
module.exports.refreshRawLink = async function(mediaObj){
|
||||
switch(mediaObj.type){
|
||||
case 'yt':
|
||||
//Scrape expiration from query strings
|
||||
//const expires = mediaObj.rawLink.match(/expire=([0-9]+)/); //Keeping this regex version I wrote at first in-case we need the speed
|
||||
const expires = new URL(mediaObj.rawLink).searchParams.get("expire");
|
||||
|
||||
//If we have a valid raw file link that will be good by the end of the video
|
||||
if(expires != null && (expires * 1000) > mediaObj.getEndTime()){
|
||||
//Return null to tell the calling function there is no refresh required for this video at this time
|
||||
return null;
|
||||
}
|
||||
|
||||
//Re-fetch media metadata
|
||||
metadata = await ytdlpUtil.fetchYoutubeVideoMetadata(mediaObj.id);
|
||||
//Refresh media rawlink from metadata
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue