Help needed with recursivly adding directory

Help
Anonymous
2010-11-02
2013-05-30

  • Anonymous
    2010-11-02

    Hello,
    I've been searching for an answer to this with no luck, so hopefully I'm not repeating an earlier question.  When I am adding media to MT 0.12.1, I click on a main directory in Filesystem view, select Timed, Full, Recursive and a scan interval of the default 1800.  It then scans and adds all media to MT, but in a somewhat random order.  As an example:

    The main directory is called "TV".  In that I have a directory called Batman The Animated Series, which in turn has 4 directory inside of that - Season 1, Season 2, Season 3, Season 4.  Also in the TV directory is another sub, called Battlestar Galactica.  This has no subdirectories inside of it:
    -TV
    ---Batman The Animated Series
    ----Season 1
    ----Season 2
    ----Season 3
    ----Season 4
    ---Battlestar Galactica

    What I get when I do a recursive scan on "TV" is the following:
    -Video
    ---All Video
    ---Directories
    ----Batman The Animated Series
    -----Season 2
    -----Season 4
    ----Season 1
    ----Season 3
    ----TV
    -----Battlestar Galactica

    Any idea why it's not nesting properly?

     
  • BT
    BT
    2010-11-02

    Are you using a custom import script or the default one? Is there any useful information being printed to the terminal or log file (usually /var/log/mediatomb.log) when importing these files?

    Just a side note regarding import settings. You can choose Inotify instead of Timed if your OS (Linux) supports it. With Inotify files will be added to the MediaTomb database as soon as there added the the directory instead of scanned at a set interval.

     
  • BT
    BT
    2010-11-02

    I ran a test with your directory structure and some sample files and I wasn't able to reproduce your issue. I used the default import script which produced the following result.

    -TV
    ---Batman The Animated Series
    ----Season 1
    ----Season 2
    ----Season 3
    ----Season 4

    The "Battlestar Galactica" directory wasn't created because it contained no sub-directories or files which is the normal behavior.

     
  • BT
    BT
    2010-11-02

    Sorry I didn't paste the full result in my previous post. The actual result was:

    -Video
    ---All Video
    ---Directories
    ----TV
    -----Batman The Animated Series
    -------Season 1
    -------Season 2
    -------Season 3
    -------Season 4

     

  • Anonymous
    2010-11-03

    I think I figured it out.  I didn't actually give you full paths, but it almost seems as if there is an issue with the number of nested directories.
    All of my TV files are in /var/hda/files/movies/TV/
    This works fine for /var/hda/files/movies/TV/Battlestar Galactica, but once I add another nested level (i.e. a directory per season) it starts to act funny, moving things out of nested order.  If you'd like to try a test with this and let me know what happens I'd appreciate it.

    As a workaround I created a symbolic link from /var/hda/files/movies/ to simply /media/movies.

     
  • BT
    BT
    2010-11-04

    I still wasn't able to reproduce it but I think I know why it might be happening. To confirm can you switch to the the external Javascript layout? You can do this by setting the following in config.xml:

    <virtual-layout type="js">
    

    After the test you should set the type attribute back to the default of builtin.

    I want to see if using the external layout makes a difference because that's what I've been using. Although the built-in one also worked for me. Make sure you completely remove the relevant files from the database (i.e. removed from PC Directory container as well), restart MediaTomb and then import them again.

    If the result is the same, could you add the following to /usr/share/mediatomb/js/import.js (location might differ on your system) just after line 154 in the addVideo function. Make a backup first so you can restore it later.

    print("location: '" + obj.location + "'");
    print("rootpath: '" + object_root_path + "'");
    print("dir: '" + dir + "'");
    

    You will again need to remove the relevant files from the database, restart and then import. This time check MediaTomb log file (usually /var/log/mediatomb.log) for the **location, rootpath and dir values. Post these values for one of the files that had it's parent directory moved out of nested order.

    The most important value is rootpath. In your case it should be /var/hda/files/movies/TV. If it's empty then that's why some directories are not where they should be. MediaTomb defines the rootpath value and although it's used extensively it's considered experimental and is undocumented. This could explain why it might be empty for some files.

    If you don't get this issue with the external layout then it's an error somewhere with the internal layout which means the MediaTomb devs would need to track this down. In the meantime you can continue to use symbolic links as a workaround.**

     
  • Eric Binet
    Eric Binet
    2010-11-07

    I have the same problem on my side.
    It seems MediaTomb's behavior is different when initially importing and when new files are found via autoscan.
    Here's an easy way to reproduce the issue :
        - Have a config file with a directory directive similar to this:
          <directory location="/mnt/data/shared/video" mode="inotify" recursive="yes"/>
        - Start MediaTomb with a new database.
        - Make sure indexing is done.
        - Create a new directory "test".
        - Create a new video file in "test" named "t.avi"

    On my setup, using only the default scripts, the "test" directory appears as a sibling of "video" in MediaTomb.

    I have looked at the source code and it seems that the "rootpath" variable is wrong for files discovered through autoscan. The problem seems to be located in content_manager.cc at line 1624 in the ContentManager::addFile function.

    The rootpath used in this function will always empty. The file's full path will, I think, fail the check_path test since it's not a directory and rootpath will remain unset. So the import script will behave very differently for imported and discovered files.

    Imported files go through the ContentManager::addRecursive function which manages rootpath correctly.

    I hope this report will help fix the issue.

     
  • BT
    BT
    2010-11-07

    bineteri,

    Thanks for the info. I suspected it was the rootpath but I couldn't pin it down because I couldn't reproduce it. Since this would affect both the internal and external import functions the only way to avoid this would be to use a custom script that doesn't rely on object_root_path.

    This would also explain why I've never come across this issue myself. My custom import script essentially does what getRootPath() does but without the use of object_root_path. I created my script way before the the object_root_path was introduced and used in the current default scripts.

    If you or kriegschrei could file a bug in the tracker that would be great. Otherwise this might never get fixed.

     
  • Jin
    Jin
    2010-11-07

    A few words to lift the mystery. Actually, I am not quite happy with the root path thing; my initial implementation was always taking the "last directory" into account, but that was not cool for structures like:

    Series Name / Season X / Filename.avi

    So root path is set depending on where you click "Add" in the UI or where autoscan is specified. If you click "Add" on the "Series Name" the root path will be different as if you click Add on the "Season X" directory.

    Unfortunately this is somewhat confusing so I am considering getting rid of the root path completely.

     
  • weaver4
    weaver4
    2011-02-26

    I am having this issue also.

    Is there a work around until the issue is resolved.  How about a Java Script patch?

    I am using sqlite, Ubuntu 10.10.

     
  • weaver4
    weaver4
    2011-02-26

    Another thing I noticed is that not all the content is showing up.  For example I have one folder that has 12 avi's in it but only 4 are in the database.

     
  • Fluffeh
    Fluffeh
    2012-01-22

    Another thing I noticed is that not all the content is showing up. For example I have one folder that has 12 avi's in it but only 4 are in the database.

    I have the same thing as well, but noticed that if there are a dozen episodes in a folder, half might appear in the place where they should be, the other half will appear in another folder (often of the same name) a directory level towards root.

     
  • Fluffeh
    Fluffeh
    2012-01-22

    After playing with it for a while, I may have found an answer by changing the following line in /etc/mediatomb/config.xml

    <virtual-layout type="builtin">

    to <virtual-layout type="js">

    I then dropped the links and re-imported my media and it seems to be working swimingly. If I add more content and it gets borked again, I will reply here, otherwise I consider this issue resolved.