Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Importing to Containers

Help
nexcompac
2011-06-30
2013-05-30
  • nexcompac
    nexcompac
    2011-06-30

    I am new to Mac and new to mediatomb.  However, I was wondering if there is a way to more effectively import videos into containers.  Under Video, i would like two categories:  Adult and Kids.  This way it will import all the kids movies to the kids folder and all the Adult movies to the Adult folder.  Currently I have all my files in m4v format per Handbreak, (would rather prefer mkv for chapters…. but thats future talk).  Then all my files are imported into iTunes which then pulled them into the Apple grouping.  I am thinking an easier way would be to create two folders, one Kids and one Adult, then have Mediatomb pull the folders into the database. 

    This would seriously beat the manual add item and typing it all out…. Data entry is not my highlight of the day…..

    First, Thoughts? 

    Second, like i said, I'm green, so i need some hand holding.

    TY

     
  • cojms1
    cojms1
    2011-07-06

    @nexcompac - I think you need to look at scripting in MediaTomb (here).
    Here's a snippet of what I do when importing Videos.  My folder structure is /Films/<Genre>/<film name>
    It also takes into account sub folders such as /Films/<Genre>/<Film Series>/<film name> e.g. /Film/Action/Bourne Series/The Bourne Identity

    function addVideo(obj)
    {
      /**** Set the Title and build the folder structure ****/
      var chain = loc.split("/");
      /* set the title */
      var title = chain[chain.length - 1];
      var pos = title.lastIndexOf('.');
      if (pos > 1) {
        title = title.substring(0, pos);
      }
      obj.title = title;
      chain.pop();
      /****  Films (so adjust the structure) ****/
      var pos = loc.indexOf("/Films/");
      if (pos != -1) {
        /* create the genre chain */
        chain.reverse();
        chain.pop();
        pos = chain.indexOf('Films');
        chain.splice(pos,0, 'Genre');
        chain.reverse();
        /* create the virtual objects */
        addCdsObject(obj, createContainerChain(chain));
        chain = new Array('Films', 'All Films', getFirstLetter(title).toUpperCase());
      }
      addCdsObject(obj, createContainerChain(chain)); /* add the object for the item */
      
    }
    /** **/
    function getFirstLetter(title) {
      var ignore = ["a", "the"];
      var first = title.charAt(0);
      for (var i = 0; i < ignore.length; i++) {
        if (title.substr(0, ignore[i].length + 1).toLowerCase() == ignore[i] + " ") {
          var first = title.charAt(ignore[i].length + 1);
          break;
        }
      }
      var temp = parseInt(first, 10);
      if (!isNaN(temp)) {
        first = "[0-9]";
      }
      return first;
    }