Textcreator LIVE V13.1 Cloud Music OS — Deel 18 van 23
Dit deel gaat direct verder onder deel 17.
Toegevoegd:
Song Management Engine V13.1
centrale song opslag
favorieten beheer
status workflow
song zoeken
koppeling met Library / Jukebox structuur
Plak dit onder deel 17.
<script>
/*
====================================================
TEXTCREATOR LIVE V13.1
PART 18
SONG MANAGEMENT ENGINE
====================================================
*/
const SONG_ENGINE={
version:"V13.1",
activeSong:null,
favorites:
JSON.parse(
localStorage.getItem(
"tc_v13_song_favorites"
)
|| "[]"
),
history:[]
};
/*
====================================================
CREATE SONG OBJECT
====================================================
*/
function createSongObject(data={}){
return {
id:
data.id ||
"SONG-"+Date.now(),
title:
data.title ||
data.Titel ||
"Nieuwe Song",
artist:
data.artist ||
data.name ||
data.Naam ||
"",
user:
data.user ||
data.User ||
"",
genre:
data.genre ||
data.Genre ||
"",
mood:
data.mood ||
data.Mood ||
"",
lyrics:
data.lyrics ||
data.Lyrics ||
data.text ||
"",
prompt:
data.prompt ||
"",
suno:
data.suno ||
data.Suno_URL ||
"",
status:
data.status ||
"Idee",
favorite:
false,
created:
new Date().toISOString()
};
}
/*
====================================================
ADD SONG TO ENGINE
====================================================
*/
function addSong(data){
const song=
createSongObject(data);
DATABASE_LAYER.collections.generated.push(
song
);
APP.generated.push(
song
);
SONG_ENGINE.history.push(
song
);
notify(
"Nieuwe song toegevoegd: "+song.title,
"success"
);
return song;
}
/*
====================================================
GET SONG
====================================================
*/
function getSong(id){
return DATABASE_LAYER.collections.generated.find(
song=>
song.id===id
);
}
/*
====================================================
SET ACTIVE SONG
====================================================
*/
function selectSong(song){
SONG_ENGINE.activeSong=song;
console.log(
"Actieve song:",
song
);
return song;
}
/*
====================================================
EDIT SONG
====================================================
*/
function updateSong(id,changes){
const song=
getSong(id);
if(!song){
notify(
"Song niet gevonden",
"error"
);
return null;
}
Object.assign(
song,
changes
);
notify(
"Song bijgewerkt",
"success"
);
return song;
}
/*
====================================================
DELETE SONG
====================================================
*/
function deleteSong(id){
const index=
DATABASE_LAYER.collections.generated.findIndex(
song=>
song.id===id
);
if(index===-1){
notify(
"Song niet gevonden",
"error"
);
return;
}
DATABASE_LAYER.collections.generated.splice(
index,
1
);
APP.generated=
DATABASE_LAYER.collections.generated;
notify(
"Song verwijderd",
"success"
);
}
/*
====================================================
FAVORITE SYSTEM
====================================================
*/
function toggleFavorite(song){
if(!song)
return;
song.favorite=
!song.favorite;
if(song.favorite){
SONG_ENGINE.favorites.push(
song
);
}
else{
SONG_ENGINE.favorites=
SONG_ENGINE.favorites.filter(
item=>
item.id!==song.id
);
}
localStorage.setItem(
"tc_v13_song_favorites",
JSON.stringify(
SONG_ENGINE.favorites
)
);
notify(
song.favorite
?
"⭐ Toegevoegd aan favorieten"
:
"☆ Verwijderd uit favorieten",
"success"
);
}
/*
====================================================
GET FAVORITES
====================================================
*/
function getFavorites(){
return SONG_ENGINE.favorites;
}
/*
====================================================
SEARCH SONGS
====================================================
*/
function searchSongs(query){
const q=
String(query)
.toLowerCase();
return APP.generated.filter(song=>{
return (
song.title.toLowerCase().includes(q)
||
song.genre.toLowerCase().includes(q)
||
song.artist.toLowerCase().includes(q)
);
});
}
/*
====================================================
STATUS WORKFLOW
====================================================
*/
const SONG_STATUS=[
"Idee",
"Demo",
"Productie",
"Afmixing",
"Gepubliceerd",
"Archief"
];
function changeSongStatus(song,status){
if(!SONG_STATUS.includes(status)){
notify(
"Ongeldige status",
"error"
);
return;
}
song.status=status;
notify(
"Status gewijzigd naar: "+status,
"success"
);
}
/*
====================================================
SONG SUMMARY
====================================================
*/
function songSummary(song){
if(!song)
return "";
return `
🎵 ${song.title}
👤 ${song.artist}
🎼 ${song.genre}
😊 ${song.mood}
📌 ${song.status}
`;
}
/*
====================================================
INIT
====================================================
*/
function initSongEngine(){
console.log(
"Song Engine actief",
SONG_ENGINE
);
}
window.addEventListener(
"DOMContentLoaded",
()=>{
initSongEngine();
});
console.log(
"Song Management Engine V13.1 loaded"
);
</script>
Einde deel 18/23.
Volgend deel 19 van 23:
Cloud Sync Engine
veilige opslaglaag
API synchronisatie
save/update verbinding met Apps Script
voorbereiding echte productieversie.