function addAudio(obj)
{
var desc = '';
var artist_full;
var album_full;
// first gather data
var title = obj.meta[M_TITLE];
if (!title) title = obj.title;
var artist = obj.meta[M_ARTIST];
if (!artist)
{
artist = 'Unknown';
artist_full = null;
}
else
{
artist_full = artist;
desc = artist;
}
var album = obj.meta[M_ALBUM];
if (!album)
{
album = 'Unknown';
album_full = null;
}
else
{
desc = desc + ', ' + album;
album_full = album;
}
if (desc)
desc = desc + ', ';
desc = desc + title;
var date = obj.meta[M_DATE];
if (!date)
{
date = 'Unknown';
}
else
{
date = getYear(date);
desc = desc + ', ' + date;
}
var genre = obj.meta[M_GENRE];
if (!genre)
{
genre = 'Unknown';
}
else
{
desc = desc + ', ' + genre;
}
var description = obj.meta[M_DESCRIPTION];
if (!description)
{
obj.meta[M_DESCRIPTION] = desc;
}
// uncomment this if you want to have track numbers in front of the title
// in album view
/*
var track = obj.meta[M_TRACKNUMBER];
if (!track)
track = '';
else
{
if (track.length == 1)
{
track = '0' + track;
}
track = track + ' ';
}
*/
// comment the following line out if you uncomment the stuff above :)
var track = '';
obj.title = title;
var tprefix = title.charAt(0).toUpperCase();
if(tprefix.search(/\W/) == 0){
tprefix = "!";
}
var chain = new Array('Audio', 'All Audio', tprefix);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
var chain = new Array('Audio', 'All Audio', ' All');
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
var aprefix = artist.charAt(0).toUpperCase();
if(aprefix.search(/\W/) == 0){
aprefix = "!";
}
chain = new Array('Audio', 'Artists', aprefix, artist, 'All Songs');
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
chain = new Array('Audio', 'Artists', ' All', artist, 'All Songs');
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
var temp = '';
if (artist_full)
temp = artist_full;
if (album_full)
temp = temp + ' - ' + album_full + ' - ';
obj.title = temp + title;
tprefix = obj.title.charAt(0).toUpperCase();
if(tprefix.search(/\W/) == 0){
tprefix = "!";
}
chain = new Array('Audio', 'All - full name', tprefix);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
chain = new Array('Audio', 'All - full name', ' All');
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
chain = new Array('Audio', 'Artists', aprefix, artist, 'All - full name');
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
chain = new Array('Audio', 'Artists', ' All', artist, 'All - full name');
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
obj.title = track + title;
chain = new Array('Audio', 'Artists', ' All', artist, album);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
chain = new Array('Audio', 'Artists', aprefix, artist, album);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
var aprefix = album.charAt(0).toUpperCase();
if(aprefix.search(/\W/) == 0){
aprefix = "!";
}
chain = new Array('Audio', 'Albums', ' All', album);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
chain = new Array('Audio', 'Albums', aprefix, album);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
chain = new Array('Audio', 'Genres', genre);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_GENRE);
chain = new Array('Audio', 'Year', date);
addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
}
søndag den 26. april 2009
mediatomb audio java script
An extension to my previous movie script for mediatomb. This script arranges the audio files in folders indexed by the first char in the artist, title...etc. So in addition to the normal directory structure, you will get sub-folders All, A, B, C, etc... This is useful if you have a large library of music and you are tired of too much scrolling.
fredag den 6. februar 2009
mediatomb movie java script
A little script that arranges Mediatomb movies in a directory structure similar to the original location of the file on your HD. The code is an improvement to the excellent tutorial posted here.
// currently no video metadata supported
function addVideo(obj) {
// define the parent dir
parent = 'downloads';
var location = obj.location.split('/');
chain = new Array();
isSubPath = false;
// iterate the dirs
for (i = 0; i < location.length-1; i++){
if (! isSubPath && location[i] == parent)
isSubPath = true;
if(isSubPath)
chain.push(location[i]);
}
addCdsObject(obj, createContainerChain(chain));
}
Abonner på:
Kommentarer (Atom)