- Update Song model to preserve original location field from Rekordbox XML - Add s3File object to Song model with S3 information alongside original location - Update SongMatchingService to link S3 files while preserving original paths - Add location-based matching for better accuracy - Update XML export to include S3 information while preserving original location - Update frontend components to show both original paths and S3 information - Add new section in SongMatching to show songs with music files - Enhance SongList to display original file paths with folder icon This ensures that: - Original file paths from Rekordbox XML are preserved - S3 information is added alongside, not replacing original data - XML export maintains compatibility while adding S3 data - Users can see both original paths and S3 streaming URLs - Matching algorithms consider original file paths for better accuracy
62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import mongoose from 'mongoose';
|
|
|
|
const tempoSchema = new mongoose.Schema({
|
|
inizio: String,
|
|
bpm: String,
|
|
metro: String,
|
|
battito: String,
|
|
}, { _id: false });
|
|
|
|
const songSchema = new mongoose.Schema({
|
|
id: { type: String, required: true, unique: true },
|
|
title: { type: String, required: true },
|
|
artist: String,
|
|
composer: String,
|
|
album: String,
|
|
grouping: String,
|
|
genre: String,
|
|
kind: String,
|
|
size: String,
|
|
totalTime: String,
|
|
discNumber: String,
|
|
trackNumber: String,
|
|
year: String,
|
|
averageBpm: String,
|
|
dateAdded: String,
|
|
bitRate: String,
|
|
sampleRate: String,
|
|
comments: String,
|
|
playCount: String,
|
|
rating: String,
|
|
location: String, // Original file path from Rekordbox XML
|
|
remixer: String,
|
|
tonality: String,
|
|
label: String,
|
|
mix: String,
|
|
tempo: tempoSchema,
|
|
// S3 file integration (preserves original location)
|
|
s3File: {
|
|
musicFileId: { type: mongoose.Schema.Types.ObjectId, ref: 'MusicFile' },
|
|
s3Key: String,
|
|
s3Url: String,
|
|
streamingUrl: String,
|
|
hasS3File: { type: Boolean, default: false }
|
|
}
|
|
}, {
|
|
timestamps: true,
|
|
versionKey: false,
|
|
toJSON: {
|
|
transform: function(doc, ret) {
|
|
ret.id = ret.id || ret._id;
|
|
delete ret._id;
|
|
delete ret.__v;
|
|
return ret;
|
|
}
|
|
}
|
|
});
|
|
|
|
// Create indexes for performance
|
|
songSchema.index({ 's3File.hasS3File': 1 });
|
|
songSchema.index({ location: 1 });
|
|
|
|
export const Song = mongoose.model('Song', songSchema);
|