Added backend functionality for channel playlist deletion

This commit is contained in:
rainbow napkin 2025-03-27 08:32:45 -04:00
parent 37f7f21c5a
commit 65b5ae9371
2 changed files with 36 additions and 1 deletions

View file

@ -596,6 +596,26 @@ channelSchema.methods.getPlaylistByName = function(name){
return foundPlaylist;
}
channelSchema.methods.deletePlaylistByName = async function(name){
//Create null value to hold our found playlist
let foundIndex = null;
//Crawl through active playlists
this.playlistCrawl((playlist, listIndex) => {
//If we found a match based on name
if(playlist.name == name){
//Yoink it's index
foundIndex = listIndex;
}
});
//splice out the given playlist
this.media.playlists.splice(foundIndex, 1);
//save the channel document
await this.save();
}
channelSchema.methods.addToPlaylist = async function(name, media){
//Create variable to hold found index
let foundIndex = null