Added random and individual queuing from playlists.

This commit is contained in:
rainbow napkin 2025-04-05 15:53:07 -04:00
parent e61d9deb52
commit e629c63b2c
6 changed files with 244 additions and 57 deletions

View file

@ -606,31 +606,6 @@ channelSchema.methods.deletePlaylistByName = async function(name){
await this.save();
}
channelSchema.methods.deletePlaylistMediaByUUID = async function(name, uuid){
//Find the playlist
let playlist = this.getPlaylistByName(name);
//splice out the given playlist
this.media.playlists[playlist.listIndex].deleteMedia(uuid);
//save the channel document
await this.save();
}
channelSchema.methods.addToPlaylist = async function(name, media){
//Find the playlist
let playlist = this.getPlaylistByName(name);
//Set media status schema discriminator
media.status = 'saved';
//Add the media to the playlist
this.media.playlists[playlist.listIndex].media.push(media);
//Save the changes made to the chan doc
await this.save();
}
channelSchema.methods.getChanBans = async function(){
//Create an empty list to hold our found bans
var banList = [];

View file

@ -52,6 +52,28 @@ playlistSchema.methods.dehydrate = function(){
}
}
playlistSchema.methods.addMedia = function(mediaList){
//For every piece of media in the list
for(let media of mediaList){
//Set media status schema discriminator
media.status = 'saved';
//Add the media to the playlist
this.media.push(media);
}
}
playlistSchema.methods.findMediaByUUID = function(uuid){
//For every piece of media in the current playlist
for(let media of this.media){
//If we found our match
if(media.uuid.toString() == uuid){
//return it
return media;
}
}
}
playlistSchema.methods.deleteMedia = function(uuid){
//Create new array to hold list of media to be kept
const keptMedia = [];
@ -69,4 +91,9 @@ playlistSchema.methods.deleteMedia = function(uuid){
this.media = keptMedia;
}
playlistSchema.methods.pickDefaultTitle = function(){
//Grab a random default title and return it
return this.defaultTitles[Math.floor(Math.random() * this.defaultTitles.length)];
}
module.exports = playlistSchema;