From cb09c139c7480bc16e22136a55eb150bc3243e09 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Sat, 15 Feb 2025 18:33:07 -0500 Subject: [PATCH] Created playlist queue schema. --- src/app/channel/media/queue.js | 6 ++-- src/app/channel/media/queuedMedia.js | 2 +- src/schemas/channel/channelSchema.js | 3 ++ src/schemas/channel/media/playlistSchema.js | 34 +++++++++++++++++++ .../channel/media/queuedMediaSchema.js | 1 + www/css/theme/movie-night.css | 2 +- 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/schemas/channel/media/playlistSchema.js diff --git a/src/app/channel/media/queue.js b/src/app/channel/media/queue.js index b398601..00fc770 100644 --- a/src/app/channel/media/queue.js +++ b/src/app/channel/media/queue.js @@ -644,8 +644,8 @@ module.exports = class{ //Get our channel const chanDB = await channelModel.findOne({name: this.channel.name}); - //If nowPlaying isn't null - if(chanDB.media.nowPlaying != null){ + //If nowPlaying isn't null and isn't what we're about to throw on + if(chanDB.media.nowPlaying != null && chanDB.media.nowPlaying.uuid.toString != mediaObj.uuid){ //Archive whats already in there since we're about to clobber the fuck out of it chanDB.media.archived.push(chanDB.media.nowPlaying); } @@ -935,7 +935,7 @@ module.exports = class{ //If the media hasn't ended yet if(wasPlaying.getEndTime() > now){ //Re-Schedule it in RAM - await this.scheduleMedia(wasPlaying, null, chanDB, true, true); + await this.scheduleMedia(wasPlaying, null, chanDB, true, true, true); //Otherwise, if it has }else{ //Null out nowPlaying diff --git a/src/app/channel/media/queuedMedia.js b/src/app/channel/media/queuedMedia.js index 7cc2994..d0dbd67 100644 --- a/src/app/channel/media/queuedMedia.js +++ b/src/app/channel/media/queuedMedia.js @@ -26,7 +26,7 @@ module.exports = class extends media{ //Set the media start time stamp this.startTimeStamp = startTimeStamp; //Create empty variable to hold early end if media is stopped early - this.earlyEnd = null; + this.earlyEnd = earlyEnd; //Set status for discriminator key this.status = 'queued'; diff --git a/src/schemas/channel/channelSchema.js b/src/schemas/channel/channelSchema.js index 0ae5b7a..99b0e34 100644 --- a/src/schemas/channel/channelSchema.js +++ b/src/schemas/channel/channelSchema.js @@ -30,6 +30,7 @@ const emoteModel = require('../emoteSchema'); const channelPermissionSchema = require('./channelPermissionSchema'); const channelBanSchema = require('./channelBanSchema'); const queuedMediaSchema = require('./media/queuedMediaSchema'); +const playlistSchema = require('./media/playlistSchema'); //Utils const { exceptionHandler, errorHandler } = require('../../utils/loggerUtils'); @@ -102,7 +103,9 @@ const channelSchema = new mongoose.Schema({ media: { nowPlaying: queuedMediaSchema, scheduled: [queuedMediaSchema], + //We should consider moving archived media and channel playlists to their own collections/models for preformance sake archived: [queuedMediaSchema], + playlists: [playlistSchema] }, //Thankfully we don't have to keep track of alts, ips, or deleted users so this should be a lot easier than site-wide bans :P banList: [channelBanSchema] diff --git a/src/schemas/channel/media/playlistSchema.js b/src/schemas/channel/media/playlistSchema.js new file mode 100644 index 0000000..cf92f8d --- /dev/null +++ b/src/schemas/channel/media/playlistSchema.js @@ -0,0 +1,34 @@ +/*Canopy - The next generation of stoner streaming software +Copyright (C) 2024-2025 Rainbownapkin and the TTN Community + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .*/ + +//NPM Imports +const {mongoose} = require('mongoose'); + +//Local Imports +const mediaSchema = require('./mediaSchema'); + +module.exports = new mongoose.Schema({ + name: { + type: mongoose.SchemaTypes.String, + required: true, + }, + media: [mediaSchema], + defaultTitles:[{ + type: mongoose.SchemaTypes.String, + required: true, + default: [] + }] +}); diff --git a/src/schemas/channel/media/queuedMediaSchema.js b/src/schemas/channel/media/queuedMediaSchema.js index eef12d5..aac45d5 100644 --- a/src/schemas/channel/media/queuedMediaSchema.js +++ b/src/schemas/channel/media/queuedMediaSchema.js @@ -37,6 +37,7 @@ const queuedProperties = new mongoose.Schema({ uuid: { type: mongoose.SchemaTypes.UUID, required: true, + unique: true } }, { diff --git a/www/css/theme/movie-night.css b/www/css/theme/movie-night.css index 9e9561c..4bec538 100644 --- a/www/css/theme/movie-night.css +++ b/www/css/theme/movie-night.css @@ -535,7 +535,7 @@ div.now-playing{ text-shadow: var(--focus-glow0); } -div.archived{ +div.archived p{ color: var(--bg2-alt1); }