Database Access within import.js

  • HelmutS

    HelmutS - 2013-02-10

    I learned - with import.js I can create my own look and feel for media browsing, which works very nice.

    Additional to store my videos files I collect a lof of metadate to each video in an additonal mysql database. Each video is taged with Genre, Year, Type like, Comic or so.

    In case there is a way to read these fields from the database I can set up more structure way to organize the virtual folders in the database. Maybe you can give me a short idea. Is there a way to access a mysql database from import.js or is there a way to call an php script instead of import.js.

    Due to the fact that import.js can also run on a timer based job, it must be a server job. In general, an access to a database should be possible or not?

    Thanks for sharing ideas with me.

  • Jin

    Jin - 2013-02-10

    I would suggest that you simply add those tags to your video files, ffmpeg can parse those fields so that you could use them in your import script.

    Another way would be, to create some custom playlist format that contains all this additional data from your database and then adapt the playlist parser script to read those extra fields and populate the media objects accordingly.

    You can not call other scripts from import.js nor can you call a different type of script, it has to be a .js script and the only way to interact with mediatomb from that js script is to use the bindings that we provide.

    Kind regars,

  • Anonymous - 2013-02-20

    if you compile libjs 1.8.0 with JS_HAS_FILE_OBJECT=1 you will have access to var file= new File(filePath) :
    I made it under fedora 16, and use it to prepare a storm in the Thecus NAS community, to compete with serviio.

    You can in the other hand use the playlist.js as said jin, almost in the same way. Bellow is an example to parse a playlist file, which is an XML file, with a dedicated function you have to write by yourself :

    function treat_nfo()
        var xml_array = [];
        var line = readln();
        line = readln();
        while (line);
        var movie = parseNfoArray(xml_array);
    switch (type)
    case 'm3u':
        print("playlist.js : debug : function treat_m3u");
    case 'nfo':
        print("playlist.js : debug : function treat_nfo");

    the thing to understand is that to rely the media obj to the scanned file you HAVE to have something linking them inside the playlist file.
    - the full media path
    - just a title (same as media file) and the file extension, only if both playlist and media file are within the same directory.


Log in to post a comment.

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

Sign up for the SourceForge newsletter:

No, thanks