Possible Help for Importing Music On a NAS

  • boilerjt

    boilerjt - 2008-11-21

    I have seen numerous reports of extreme slow speeds when importing music on a NAS.  I am finding that the less tag info used and less menu items that are created speed up the import process.  Feel free to try the following and see if this helps.

    First of all, you must have spidermonkey javascript support compiled into MediaTomb and this must be set in config.xml: <virtual-layout type="js"> not <virtual-layout type="builtin">.

    In the import.js file (in share/mediatomb/js on my NAS), replace the AddAudio()  function with this:

    function addAudio(obj)
    var desc = '';
    var artist_full;
    var album_full;
    var NumChars = "0123456789";

    // first gather data
    var title = obj.meta[M_TITLE];
    if (!title) title = obj.title;

    var artist = obj.meta[M_ARTIST];
    var first_letter = '';
    if (!artist) {
    artist = 'Unknown';
    first_letter = 'Unknown';
    artist_full = null;
    } else {
    artist_full = artist;
    first_letter = artist.charAt(0).toUpperCase();
    if (NumChars.indexOf(first_letter) != -1)
       first_letter ='0-9';

    desc = artist;

    var album = obj.meta[M_ALBUM];
    if (!album) {
    album = 'Unknown';
    album_full = null;
    } else {
    desc = desc + ', ' + album;
    album_full = album;

    var track = obj.meta[M_TRACKNUMBER];
    if (!track)
    track = '';
    else {
    if (track.length == 1) {
    track = '0' + track;
    track = track + ' ';

    chain = new Array('Audio', first_letter, artist, album);
    obj.title = track + title;
    addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);

    chain = new Array('Audio', first_letter, artist, '-All Songs-');
    obj.title = album_full + ' - ' + track + title;
    addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);

    This script is from one posted in the scripting wiki with a few tweaks.  The menu structure is Music-First Letter Of Artist-Artists-Albums-Songs and that is it.  There is no genre, all songs, or all albums that are present in the default import.  Let me know if this works for anyone.


    • boilerjt

      boilerjt - 2008-11-21

      One more thing that is equally (if not more ) important when importing music from a NAS.  If you have playlists within the music directory, each playlist has to be processed as well and this can slow down the import.  In my case, I do use some playlists, but they are not mixed in amongst my music files.   I keep them in a separate directory and use an absolute path to each song within the playlist.  When I wish to import a playlist (or group of playlists), I use the Web UI to pick and choose which ones I would like to import.  For example, here is my directory structure:

      Audio - Music-Artist-Album-Song

      In this layout, I can maintain a playlist for each album and playlists which mix artists/albums/etc.

      Another solution if you do not use playlists is to edit playlist.js and make it ignore all playlists...


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks