Created Playlist Media Schema.

This commit is contained in:
rainbow napkin 2025-03-21 07:32:37 -04:00
parent cb09c139c7
commit 59f097db39
4 changed files with 66 additions and 4 deletions

View file

@ -14,12 +14,13 @@ This new codebase intends to solve the following issues with the current CyTube
- General Clunk - General Clunk
- Less Unique Community Identity - Less Unique Community Identity
Canopy intends to be a simple node/express.js app. It leverages yt-dlp and the internet archive cli utility for metadata gathering. Persistant storage is handled by mongodb, as it's document based nature inherintly works well for cleanly storing large config documents for user/channel settings, and the low use of inter-collection references within the canopy software. All hardcore security functions like session handling and password hashing are handled by industry-standard open source libraries such as express-sessions and bcrypt, however it IS hobbiest software, and it should be treated as such. Canopy intends to be a simple node/express.js app. It leverages the piped and the internet archive REST api's, as well as yt-dlp, for metadata gathering. Persistant storage is handled by mongodb, as it's document based nature inherintly works well for cleanly storing large config documents for user/channel settings, and the low use of inter-collection references within the canopy software. All hardcore security functions like session handling, CSRF mitigation, and password hashing are handled by industry-standard open source libraries such as express-sessions, csrf-sync, and bcrypt, however it IS hobbiest software, and it should be treated as such.
The Canopy codebase does not, and never will contain: The Canopy codebase does not, and never will contain:
- Advertisements (targetted or otherwise) - Advertisements (targetted or otherwise)
- Proprietary Code - Proprietary Code
- 'Analytics/Telemtry' spyware - 'Analytics/Telemtry' spyware
- The use of video sources which require proprietary 'Digital ~~Rights Management~~ Ristricitons Malware' such as Widevine.
Thirdparty media providers may or may not contain all of the above atrocities :P, always use an ad-blocker! Thirdparty media providers may or may not contain all of the above atrocities :P, always use an ad-blocker!

View file

@ -0,0 +1,60 @@
/*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 <https://www.gnu.org/licenses/>.*/
//NPM Imports
const {mongoose} = require('mongoose');
//Local Imports
const mediaSchema = require('./mediaSchema');
const media = require('../../../app/channel/media/media');
const playlistMediaProperties = new mongoose.Schema({
uuid: {
type: mongoose.SchemaTypes.UUID,
required:true,
unique: true
}
},
{
discriminatorKey: 'status'
});
//Schema Middleware
playlistMediaProperties.pre('save', async function (next){
//If the UUID was modified in anyway
if(this.isModified("uuid")){
//Throw that shit out and make a new one since it's probably either null or a leftover from some channel queue
this.uuid = crypto.randomUUID();
}
//Keep it moving
next();
});
//methods
playlistMediaProperties.methods.rehydrate = function(){
//Return item as a full phat, standard media object
return new media(
this.title,
this.fileName,
this.url,
this.id,
this.type,
this.duration
);
}
module.exports = mediaSchema.discriminator('saved', playlistMediaProperties);

View file

@ -18,14 +18,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
const {mongoose} = require('mongoose'); const {mongoose} = require('mongoose');
//Local Imports //Local Imports
const mediaSchema = require('./mediaSchema'); const playlistMediaSchema = require('./playlistMediaSchema');
module.exports = new mongoose.Schema({ module.exports = new mongoose.Schema({
name: { name: {
type: mongoose.SchemaTypes.String, type: mongoose.SchemaTypes.String,
required: true, required: true,
}, },
media: [mediaSchema], media: [playlistMediaSchema],
defaultTitles:[{ defaultTitles:[{
type: mongoose.SchemaTypes.String, type: mongoose.SchemaTypes.String,
required: true, required: true,

View file

@ -45,6 +45,7 @@ const queuedProperties = new mongoose.Schema({
}); });
//methods //methods
//Rehydrate to a full phat queued media object
queuedProperties.methods.rehydrate = function(){ queuedProperties.methods.rehydrate = function(){
return new queuedMedia( return new queuedMedia(
this.title, this.title,