Problems with Youtube

1 2 > >> (Page 1 of 2)
  • cavetroll74

    cavetroll74 - 2009-10-22

    Hi there

    I have a problem and I hope somebody can help me out. I am running Ubuntu 9.04 server 64-bit. I recently compiled and installed mediatomb0.12 using this guide:
    I m having problems with my youtube configuration, though. I can t get my playlists or other things to show up in the database. It just keeps showing my Favourites and one video the is Rated 4 stars. It just keeps showing the default categories, I guess.
    As far as Youtube playback is concerned, I`m getting the following error in mediatomb.log: ERROR: Failed to get URL for video with id (step 1)youtube_gdata

    I am streaming data through a PS3 but whenever I tell it to play Youtube clips, it gives me a network errror. Other online content like Apple Trailers works fine.

    Thanks for your help.

  • Greg Smith

    Greg Smith - 2009-11-05

    I have the exact same problem.

    It appears to be a change in the RSS feed from youtube, preventing the XML parser from finding the correct link. I'm going through the code to try to find an easy fix.

  • Greg Smith

    Greg Smith - 2009-11-05

    I've fixed part of the problem, inserting the 3  lines below into the function Ref<CdsObject> YouTubeContentHandler::getNextObject() in file around line 220.

            //existing code
            //new code
            int amp = temp.index('&');
            if (amp > 0 )
                 temp = temp.substring( 0, amp );
            // existing code   
            int eq = temp.rindex('=');
            if (eq > 0 )
                 temp = temp.substring(eq + 1);

    It now properly parses the the video id, populates the db and creates the proper URL requests. However, the response returned from youtube no longer contains the data mediatomb expects, so playing the the video still fails.

  • cavetroll74

    cavetroll74 - 2009-11-05

    Thanks for your answer! That seems to work well. It's unfortunate that the playback still doesn't work, though :(
    A similar problem with the database seems to exist with Apple Trailers. "All Trailers" are there but the categories appear only randomly and are almost empty. Any suggestions?

  • Greg Smith

    Greg Smith - 2009-11-07

    OK I've got youtube videos to play. First, forgive me if this answer sucks. I don't normally code for linux or in C++ (or ever dealt with regex or JSON)
    Someone who knows what they're doing could probably flesh this out so it makes sense (such as adding the json dependecies via configure)

    First, compile and install libjson (

    Copy the include files from jsoncpp/include/json to mediatomp/src/json. (You can also copy the libjson*.a to that folder to.)

    Then add the reference to libjson to your existing makefile ( mediatomb/build/Makefile)

        mediatomb_LDADD = \
        libmediatomb.a \
        $(top_srcdir)/tombupnp/build/libtombupnp.a \
        $(top_srcdir)<--path to--->/libjson_linux-gcc-4.4.1_libmt.a \
        $(LIBEXIF_LDFLAGS) \

    Then I changed mediatomb/src/

        > #include "json/json.h"
        < #define YOUTUBE_URL_PARAMS_REGEXP   "var swfArgs =.*\"t\": \"(+)\""
        > #define YOUTUBE_URL_PARAMS_REGEXP   "SWF_ARGS.*\\}"
        > #define YOUTUBE_URL_PARAM_L         "l"
        > #define YOUTUBE_URL_PARAM_SK        "sk"
        >     Json::Value root;
        >     Json::Reader reader;
        <         params = trim_string(matcher->group(1));
        >         params = trim_string( matcher->group( 0 ) );
        >         int brace = params.index( '{' );
        >         if ( brace > 0 )
        >             params = params.substring( brace );
        >         brace = params.index( '}' );
        >         if ( brace > 0 )
        >             params = params.substring( 0, brace + 1 );
        <     params = _(YOUTUBE_URL_GET) + YOUTUBE_URL_PARAM_VIDEO_ID + '=' +
        <              video_id + '&' + YOUTUBE_URL_PARAM_T + '=' + params;
        >     bool parsingSuccessful = reader.parse( params.c_str(), root );
        >     params = _(YOUTUBE_URL_GET) + YOUTUBE_URL_PARAM_VIDEO_ID + '=' + video_id +
        >              '&' + YOUTUBE_URL_PARAM_L  + '=' + root.get("l" , "" ).asCString() +
        >              '&' + YOUTUBE_URL_PARAM_SK + '=' + root.get("sk", "" ).asCString() +
        >              '&' + YOUTUBE_URL_PARAM_T  + '=' + root.get("t" , "" ).asCString();

    Then go through the normal make, sudu make install steps and run.

    Note this doesn't detect mp4 files.

    Again I'm sorry these steps are so bad, I hope someone can make them better. I'm just happy I can watch Charlie the Unicorn on my TV!

    I'll look into the apple trailers next

    Good luck

  • Greg Smith

    Greg Smith - 2009-11-10

    I haven't been able to reproduce the problems with apple trailers, so I'm not sure if can help with that problem. sorry.

  • Greg Smith

    Greg Smith - 2009-11-11


    I looked at the code some more. Your best bet is to start mediatomb up in debug mode ( -D ), and specify a log file ( -l logfile) then when you start losing categories, check the file for any errors when refreshing content.

  • cavetroll74

    cavetroll74 - 2009-11-11


    Sorry for my late reply!
    I have to admit that your Youtube solution is a bit over my head ;) Maybe I find some time over the weekend to look into it. Many thanks for that!
    The fact that the Apple Trailers disappear is quite strange. It seems to be random. They come in fine when I blow away the database and re-import. After 1 or 2 days the categories simply disappear. I can see everything in the AllTrailers-section, though. I'll follow your advice and try to debug mediatomb. I'll keep you posted.
    Again, thanks for your great help!

  • SSamiK

    SSamiK - 2009-11-18

    Is this fixed in SVN?

  • Greg Smith

    Greg Smith - 2009-11-18

    I hope not (at least not using the above code) It's not some of my best work :)

    There's no documentation about the need for jsoncpp. The regex really needs to work better.

    Also there should be a check to see if an HD version is available.

    The code works but not well. If I ever get some more free time, I'll revisit it to make it correct.

  • Jin

    Jin - 2009-12-03

    I just got back from my "car restoration holidays" and also got informed that YT is broken. I'll have a look at it…

  • Jin

    Jin - 2010-01-08

    Please test latest SVN, YT should again be working starting with revision 2043.

    I still have something on my TODO list, I need to add more formats, to allow better format selection from config.xml, but apart from that the old functionality should be restored now.

  • Greg Smith

    Greg Smith - 2010-01-10

    It works for me. Thanks!

  • Jin

    Jin - 2010-01-10

    > Also there should be a check to see if an HD version is available.

    Btw that should work, could you please check that as well?

  • Greg Smith

    Greg Smith - 2010-01-13

    It doesn't appear to work.

    I'll have to verify it's not my problem, but the network traces show we're requesting fmt=18, even when 'IS_HD_AVAILABLE': true.

    I'll let you know what I find.

  • Greg Smith

    Greg Smith - 2010-01-13

    I guess I should verify I have the correct config.

    I should have:

    format="mp4" and hd="yes"

    in my youtube setting, right? I'm thinking the hd part could be wrong???


  • Jin

    Jin - 2010-01-13

    Yes, your config looks OK, so it's very well possible that the HD part is broken. I anyway need to add more formats…

    I did not yet had time to test it properly, I fixed it on a mobile connection and want to retest it when I am at something that has more bandwidth, so it could still be buggy.

  • Greg Smith

    Greg Smith - 2010-01-13

    It appears to be an issue with the regex matcher .which I really need to learn someday.

    Anyway, the line to match is

    …'IS_HD_AVAILABLE': true,

    the current regex  "IS_HD_AVAILABLE *: *(*);" and doesn't match.

    I tried "IS_HD_AVAILABLE': *" which matches, but fails the later comparison to "true", probably because of the trailing comma. What should I be trying?

    thanks again

  • Jin

    Jin - 2010-01-13

    Please try svn revision 2053, it looks like I simply forgot to update the regular expression for HD content :)

    Btw I also have a hard time with regular expressions, our RExp class is simply a wrapper around regex.h

  • Greg Smith

    Greg Smith - 2010-01-13

    That works!

    fmt=22 is requested and the video.mp4 file download is started.

    My directv box chokes on it, but the PS3 plays it just fine.

    Thanks for all your work.

  • Jin

    Jin - 2010-01-14

    Can you please retest with revisoin 2055? Some guys reported that it did not compile on their systems, gcc did not like the escaped comma in the regexp for some reason, I removed the escaping but i do not know if it breaks the regexp when searching for the HD value…..

  • Greg Smith

    Greg Smith - 2010-01-15

    Yes, The HD detection still works.


  • Eonic

    Eonic - 2010-01-15

    Hello, I'm not sure if this is the proper place to add my issue with compiling revision 2055. I am trying because I want youtube to work, though. Using gcc 4.3.2, I get the following something like this:

    x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I.. -I../tombupnp/upnp/inc    -I../src -I../tombupnp/ixml/inc -I../tombupnp/threadutil/inc -I../tombupnp/upnp/inc -I..  -I/usr/include/mysql -DHAVE_ERRNO_AS_DEFINE=1 -I/usr/include/js -I/usr/include/taglib       -pthread       -I/usr/include -I/usr/include -DDVDNAV_USES_EXTERNAL_DVDREAD -O2 -march=native -pipe -MT libmediatomb_a-ffmpeg_handler.o -MD -MP -MF .deps/libmediatomb_a-ffmpeg_handler.Tpo -c -o libmediatomb_a-ffmpeg_handler.o `test -f '../src/metadata/' || echo './'`../src/metadata/
    mv -f .deps/libmediatomb_a-extractor_handler.Tpo .deps/libmediatomb_a-extractor_handler.Po
    x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I.. -I../tombupnp/upnp/inc    -I../src -I../tombupnp/ixml/inc -I../tombupnp/threadutil/inc -I../tombupnp/upnp/inc -I..  -I/usr/include/mysql -DHAVE_ERRNO_AS_DEFINE=1 -I/usr/include/js -I/usr/include/taglib       -pthread       -I/usr/include -I/usr/include -DDVDNAV_USES_EXTERNAL_DVDREAD -O2 -march=native -pipe -MT libmediatomb_a-metadata_handler.o -MD -MP -MF .deps/libmediatomb_a-metadata_handler.Tpo -c -o libmediatomb_a-metadata_handler.o `test -f '../src/' || echo './'`../src/
    ../src/metadata/ In member function 'virtual zmm::Ref<IOHandler> FfmpegHandler::serveContent(zmm::Ref<CdsItem>, int, off_t*)':
    ../src/metadata/ error: 'video_thumbnailer_create' was not declared in this scope
    ../src/metadata/ error: 'video_thumbnailer_create_image_data' was not declared in this scope
    ../src/metadata/ error: 'video_thumbnailer_generate_thumbnail_to_buffer' was not declared in this scope
    ../src/metadata/ error: 'video_thumbnailer_destroy_image_data' was not declared in this scope
    ../src/metadata/ error: 'video_thumbnailer_destroy' was not declared in this scope
    mv -f .deps/libmediatomb_a-metadata_handler.Tpo .deps/libmediatomb_a-metadata_handler.Po
    make: ***  Error 1
    make: *** Waiting for unfinished jobs….
    mv -f .deps/libmediatomb_a-config_manager.Tpo .deps/libmediatomb_a-config_manager.Po

    Any ideas?

  • Eonic

    Eonic - 2010-01-15

    I removed dvd support and it compiled. Just as well really, I've not had time to properly debug that, but reading from dvd's kept crashing my mediatomb anyway. Probably because I had to install some packages which were markes as masked/unstable.

    Anyway, now YouTube works. Excellent stuff, Jin. :-)

  • Eonic

    Eonic - 2010-01-16

    Actually, YouTube playback for me is very jittery (a lot of lag) even without hd="yes".  I'm using these settings:

    <YouTube enabled="yes" hd="no" format="mp4" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude">

    I'm serving the content to my PS3 and have disabled transcoding for flv data.

1 2 > >> (Page 1 of 2)

Log in to post a comment.