Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Suggestion: Replace js-scripts with python

2011-01-11
2013-05-30
  • Fabian Wenzel
    Fabian Wenzel
    2011-01-11

    Hi again,

    one last e-mail: I noticed that the current ubuntu versions of mediatomb ship without scripting support. This is due to the fact that maintaining js scripting seems to be hard (there have been posts about obsolete versions and increased effort regarding finding the correct version etc.).

    One post also suggested switching the scripting support from JavaScript to python, and I can join this request.

    There are only three scripting files (if I have seen this correctly), and python resembles JavaScript in terms of data structures, so I don't think the effort would be that high.

    If the interface layer (that is currently using xulrunner) should not work with the Python C interface (which would keep dependencies at minimum), then I would suggest to use boost::python. I provides a c++ api to access python datastructures more or less in the same way as using python itself. In other words, the wrapping layer could be kept really tiny in terms of source code (with the drawback of adding a boost python dependency).

    Again, I would think that scripting the import functionality of mediatomb with JavaScript might not be the perfect technology. JavaScript is great for rendering web pages, but maybe not for generic scripting (i.e. when importing tracks to a uPNP database). This is not due to the language itself (I mentioned already that the data structures actually resemble the python ones), but due to the fact that many dependencies are needed. In fact, I had to install 100 MB on my ubuntu system in order to get xulrunner running.

    My feeling would be that it is worth some effort in switching.

    Regards!

     
  • theli_ua
    theli_ua
    2011-05-11

    python instead of JS would be perfect

     
  • chowjok
    chowjok
    2011-08-22

    Python or perl would be perfect. This will allow the possibility of looking up IMDB or Last.fm, etc in the import scripts.

     
  • alex sayle
    alex sayle
    2011-09-19

    Hello there.

    I've got a patch going to do exactly this, although I will not be going near boost. Frankly there is no need for it. ( not to mention that I have a lot of rude things to say against boost )

    as far as I can tell (so far) ( from code diving ) is that the JS engin is only used in the importing to provide an abstraction.

    The way I'm coding it up now is to replace this section and this section alone with a python run time ( 2.6 is mu current target ).

    The py code would then look like the following.

    def do_magic_with_video(media):
       # do cool stuff here.
    import mediatomb
    mediatomb.log("Starting Import Script")
    
    media = mediatomb.MediaTomb()
    if  media.mime = "video":
        do_magic_with_video(media)
    mediatomb.log("end import script")
    

    The mediatomb module would only be availble inside the MediaTomb Runtime as its defined in C(++) with in the runtime context.

    I'm happy to take suggestions on what the Python API should look like.

    I'll be clear that I'm doing this for my own needs and my dislike for ECMA Script.  I'm not going to promise changes that I haven't looked into, so no promises regarding xulrunner :)