Deep Breath!!!

Help
iain best
2011-02-24
2013-05-30
  • iain best
    iain best
    2011-02-24

    Hi Guys,

    I feel slight stressed at trying to get this to work, I have been working on and off since 2007, so maybe its just not meant to be.

    Anyway in a nutshell, my music works well and once I go to the "File System" and say add to the music folder it imports it into the  DB in a really good structure. (Artist, Year etc)

    However I can't get my Videos or Images to do the same, when I go into the "File system" and add the videos and Images  Mediatomb imports the folders/files into the DB under "PC Directory" and doesnt change the Mimetype to the correct type to enable them to show and play.

    Now I suppect that this is all down to the incorrect Mimetype in my scripts but for the life of me cannot work it out!!!!

    Please can you help me get this resolved once and for all?

    <?xml version="1.0" encoding="UTF-8"?>
    <config xmlns="http://mediatomb.cc/0.10.0/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/0.10.0/config http://mediatomb.cc/0.10.0/config.xsd">
      <server>
        <ui enabled="yes">
          <accounts enabled="no" session-timeout="30"/>
        </ui>
        <name>MediaTomb</name>
        <udn>uuid:2c9e2217-b256-4761-9279-918ab58c6084</udn>
        <home>/var/mediatomb/.mediatomb</home>
        <webroot>/opt/mediatomb/share/mediatomb/web</webroot>
        <storage driver="sqlite3">
          <database-file>mediatomb.db</database-file>
        </storage>
      </server>
      <import hidden-files="no">
        <scripting script-charset="UTF-8">
          <common-script>/opt/mediatomb/share/mediatomb/js/common.js</common-script>
          <playlist-script>/opt/mediatomb/share/mediatomb/js/playlists.js</playlist-script>
          <virtual-layout type="builtin">
            <import-script>/opt/mediatomb/share/mediatomb/js/import.js</import-script>
          </virtual-layout>
        </scripting>
        <mappings>
          <extension-mimetype ignore-unknown="no">
    <map from="avi" to="video/avi"/>
    <map from="avi" to="video/divx"/>
            <map from="mp3" to="audio/mpeg"/>
            <map from="ogg" to="application/ogg"/>
            <map from="asf" to="video/x-ms-asf"/>
            <map from="asx" to="video/x-ms-asf"/>
            <map from="wma" to="audio/x-ms-wma"/>
            <map from="wax" to="audio/x-ms-wax"/>
            <map from="wmv" to="video/x-ms-wmv"/>
            <map from="wvx" to="video/x-ms-wvx"/>
            <map from="wm" to="video/x-ms-wm"/>
            <map from="wmx" to="video/x-ms-wmx"/>
            <map from="m3u" to="audio/x-mpegurl"/>
            <map from="pls" to="audio/x-scpls"/>
          </extension-mimetype>
          <mimetype-upnpclass>
            <map from="audio/*" to="object.item.audioItem.musicTrack"/>
            <map from="application/ogg" to="object.item.audioItem.musicTrack"/>
            <map from="video/*" to="object.item.videoItem"/>
            <map from="image/*" to="object.item.imageItem"/>
          </mimetype-upnpclass>
          <mimetype-contenttype>
            <treat mimetype="audio/mpeg" as="mp3"/>
            <treat mimetype="application/ogg" as="avi"/>
            <treat mimetype="audio/x-flac" as="flac"/>
            <treat mimetype="image/jpeg" as="jpg"/>
            <treat mimetype="audio/x-mpegurl" as="playlist"/>
            <treat mimetype="audio/x-scpls" as="playlist"/>
          </mimetype-contenttype>
        </mappings>
      </import>
    </config>

     
  • iain best
    iain best
    2011-02-24

    // Default MediaTomb import script.
    // see MediaTomb scripting documentation for more information

    /*MT_F*
       
        MediaTomb - http://www.mediatomb.cc/
       
        import.js - this file is part of MediaTomb.
       
        Copyright (C) 2006-2007 Gena Batyan <bgeradz@mediatomb.cc>,
                                Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
                                Leonhard Wimmer <leo@mediatomb.cc>
       
        This file is free software; the copyright owners give unlimited permission
        to copy and/or redistribute it; with or without modifications, as long as
        this notice is preserved.
       
        This file 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.
       
        $Id: import.js 1353 2007-06-07 14:40:33Z lww $
    */

    function addAudio(obj)
    {

        var desc = '';
        var artist_full;
        var album_full;
       
        // first gather data
        var title = obj.meta;
        if (!title) title = obj.title;
       
        var artist = obj.meta;
        if (!artist)
        {
            artist = 'Unknown';
            artist_full = null;
        }
        else
        {
            artist_full = artist;
            desc = artist;
        }
       
        var album = obj.meta;
        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;
        if (!date)
        {
            date = 'Unknown';
        }
        else
        {
            date = getYear(date);
            desc = desc + ', ' + date;
        }
       
        var genre = obj.meta;
        if (!genre)
        {
            genre = 'Unknown';
        }
        else
        {
            desc = desc + ', ' + genre;
        }
       
        var description = obj.meta;
        if (!description)
        {
            obj.meta = desc;
        }

    // uncomment this if you want to have track numbers in front of the title
    // in album view
       
    /*   
        var track = obj.meta;
        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 = '';

        var chain = new Array('Audio', 'All audio');
        obj.title = title;
        addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
       
        chain = new Array('Audio', 'Artists', artist, 'All songs');
        addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
       
        chain = new Array('Audio', 'All - full name');
        var temp = '';
        if (artist_full)
            temp = artist_full;
       
        if (album_full)
            temp = temp + ' - ' + album_full + ' - ';
       
        obj.title = temp + title;
        addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
       
        chain = new Array('Audio', 'Artists', artist, 'All - full name');
        addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
       
        chain = new Array('Audio', 'Artists', artist, album);
        obj.title = track + title;
        addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
       
        chain = new Array('Audio', 'Albums', album);
        obj.title = track + title;
        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);
    }

    // currently no video metadata supported
    function addVideo(obj)
    {
        var chain = new Array('Video');
        addCdsObject(obj, createContainerChain(chain));
    }

    function addImage(obj)
    {
        var chain = new Array('Photos', 'All Photos');
        addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER);

        var date = obj.meta;
        if (date)
        {
            chain = new Array('Photos', 'Date', date);
            addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER);
        }
    }

    // main script part

    if (getPlaylistType(orig.mimetype) == '')
    {
        var arr = orig.mimetype.split('/');
        var mime = arr;
       
        // var obj = copyObject(orig);
       
        var obj = orig;
        obj.refID = orig.id;
       
        if ((mime == 'audio') || (orig.mimetype == 'application/ogg'))
        {
            addAudio(obj);
        }
       
        if (mime == 'video')
        {
            addVideo(obj);
        }
       
        if (mime == 'image')
        {
            addImage(obj);
        }
    }

     
  • iain best
    iain best
    2011-02-24

    Ok it's working now, however it just imports the videos in a list with no structure….
    ?

     
  • BT
    BT
    2011-02-25

    It appears you have a really old MediaTomb version installed. The latest version 0.12.0 has an improved import script, especially for videos.

     
  • BT
    BT
    2011-02-25

    The latest version is actually 0.12.1.