Help With Custom onlinemedia.xml – Youtube

Home Forums Help and Support Help With Custom onlinemedia.xml – Youtube

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #23232
    stzh
    Participant

    Hi,

    I would like to set up some custom ‘playlists’ containing the most recent uploads by a certain Youtube uploader.

    My attempt to use:

    Works, but results in a list that is not in order by most recent upload.

    Please can someone help me by either letting me know which other parameters are accepted by the youtube.php script, or if it is possible to link directly to a Youtube API page, like one of these below:




    I’ve tested all of the above and none of them work: all result in the buffering alert being shown, then a ‘Error loading file!’ error.

    I tried the API because I assume, perhaps incorrectly, that the youtube.php script queries the Youtube API and returns some / all of the resulting XML.

    Thanks for your attention.

    EDIT:

    By spoofing my user-agent ( WiiMC for all non-version fields, and 1.01 for version ) I’ve managed to retrieve the format required.

    Here is a snippet, for any others interested in the same thing:

    [playlist]

    File1=http://www.youtube.com/watch?v=l9gPGYqpAuA
    Title1=HD Starcraft 2 BoxeR v Set
    Length1=-1

    File2=http://www.youtube.com/watch?v=cmD5b85x_rw
    Title2=HD Starcraft 2 IdrA v Ddoro
    Length2=-1

    ( ... )


    Is the content of youtube.php open-source, if so is it available? I would very much like to extend it to fit my needs, I’m currently a PHP programmer.

    Thanks again for your time.

    #27619
    cadbusca
    Participant

    Could you explain more? WIIMC already has the user agent set in http.cpp so I don’t understand what you did differently, or what you sent to retreive that playlist, or where you sent the request(wiimc.org or youtube.com)?

    I also don’t see anything in the playlist you have retreived by spoofing that will allow you to order by most recent upload. Are you suggesting that the playlist is in that order but the original WIIMC query response has altered that order? I already have an option to sort the query response by name rather than the order returned by WIIMC, and that could be extended.

    I’d also like to understand how you will use the returned playlist within WIIMC to create your custom playlists?

    Seems to be lots of potential here. Any thoughts on retreiving the captions/subtitles from youtube too? Thanks.

    #27620
    stzh
    Participant

    @jhb50 wrote:

    Could you explain more? WIIMC already has the user agent set in http.cpp so I don’t understand what you did differently, or what you sent to retreive that playlist, or where you sent the request(wiimc.org or youtube.com)?

    Hi jhb50,

    I wasn’t planning on changing any cpp source – by ‘spoof my user agent’ I meant that I used https://addons.mozilla.org/en-US/firefox/addon/59/ and set my user agent to ‘WiiMC’, then loaded http://www.wiimc.org/media/youtube.php?q=HDStarcraft in Firefox. All I wanted to know was the format WiiMC expects to receive.

    @jhb50 wrote:

    I also don’t see anything in the playlist you have retreived by spoofing that will allow you to order by most recent upload. Are you suggesting that the playlist is in that order but the original WIIMC query response has altered that order? I already have an option to sort the query response by name rather than the order returned by WIIMC, and that could be extended.

    No, the playlist isn’t in order. As I don’t have the source ‘youtube.php’, the file on this site ( wiimc.org/media/youtube.php ), I’m not quite sure how the playlists are being retrieved, so I have no idea what order the search returns playlists in.

    I plan on making my own version that accepts a few more search parameters, at the moment I’m interested in searching for videos by a certain user and having results returned ordered by most recent upload. I will use the Youtube API http://code.google.com/apis/youtube/getting_started.html#data_api and PHP to do this.

    For my example: user=HDStarcraft, order_by=published, the API link is:

    http://gdata.youtube.com/feeds/base/users/HDstarcraft/uploads?alt=rss&v=2&orderby=published

    All I have to do is read that feed and convert it from pretty rss to the simple list format I pasted in my OP.

    @jhb50 wrote:

    I’d also like to understand how you will use the returned playlist within WIIMC to create your custom playlists?

    It will hopefully work just like the wiimc Youtube playlists – be a list of videos for user X ordered by date published. All I really want at this stage is a way for me to watch HDStarcraft replays on my TV, so when I have a break from programming, I’m actually having a break from the computer instead of sitting in the same position.

    @jhb50 wrote:

    Seems to be lots of potential here. Any thoughts on retreiving the captions/subtitles from youtube too? Thanks.

    Yes I agree – what I will hopefully be able to provide sometime today is a PHP file / class that can be queried using more advanced parameters, intended to be used to setup RSS feed-style lists of Youtube users. With a little more work it may become more general.

    Captions:

    Captions may be retrieved, read more here: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_captions.html#Retrieve_Caption_Set. I would assume WiiMC would need modification in order to be able to read and display these? If given a required format I could write some PHP that took queries and returned captions in said format without difficulty.

    Please note that I don’t intend to touch any C++, it’s been many years since I did so, and my job doesn’t permit me the time to get back into it right now. What I intend is a php file to be used in the same way as youtube.php – one will still have to enter the address manually ( though I will look at making a ‘search’ entry and see how I could make that work ) in the onlinemedia.xml file.

    Something like this:

    #27621
    stzh
    Participant

    http://pagesofinterest.net/wiimc/youtube.php

    For now, one can use this URL to query like so:

    For a user’s videos as a list, similar to an RSS feed for a blog:

    This will show about 20-24 of the most recent uploads by the given user, with most recent videos appearing first.

    Url: http://pagesofinterest.net/wiimc/youtube.php?q=USERNAME%26type=user

    Both q and type are required.

    Required parameters:

    • q = the username, e.g. “HDStarcraft”
    • type = ‘user’

    For a more general search:

    This may be used to generate more customizable playlists.

    URL: http://pagesofinterest.net/wiimc/youtube.php?q=QUERY_STRING

    Possible parameters:

    • q = the text you are searching for, e.g. ‘wiimc rocks’
    • order_by = optional the order you want results in, one of: relevance, view_count, updated, or rating
    • safe = optional level of safe-search you want imposed, one of: none, moderate or strict
    • author = optional the author of the videos you’re searching for

    Examples:

    In the format required by onlinemedia.xml.









    Now I can have HDStarcraft’s Youtube feed on my Wii!

    For more information on the Youtube API: http://code.google.com/apis/youtube/2.0/developers_guide_php.html

    There are many possibilities, if there is a C++ programmer out there interested in extending WiiMC’s Youtube functions further, I’m able to handle the PHP side.

    Does what I want anyway, here is the source:

    <?php
    //Requires: http://framework.zend.com/download/gdata/
    ini_set("include_path", '/must/point/to/folder/containing/Zend_folder');
    require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
    Zend_Loader::loadClass('Zend_Gdata_YouTube');

    class wiiMcPlaylistRetriever extends Zend_Gdata_YouTube {

    const YOUTUBE_BASE = 'http://gdata.youtube.com/';
    const STANDARD_FEED_PREFIX = 'feeds/api/standardfeeds/';
    const YOUTUBE_USER_SEARCH = 'feeds/base/users/';

    const PLAYLIST_HEAD = '[playlist]';

    // $_GET keys:
    const QUERY = 'q';
    const QUERY_TYPE = 'type'; // user, author
    const ORDER_BY = 'order_by'; // relevance, view_count, updated, or rating
    const SAFE_SEARCH = 'safe'; // none, moderate or strict
    const AUTHOR = 'author';

    // Possible $_GET values:
    const QUERY_TYPE_USER = 'user';
    const QUERY_TYPE_GENERAL = 'general';

    function __construct()
    {
    parent::__construct();
    $this->setMajorProtocolVersion(2);

    $this->beginRetrieval();
    }

    function beginRetrieval()
    {

    $args = Array();
    if( isset( $_GET[ self::QUERY ] ) ){ // This is a search
    $args[ self::QUERY ] = $_GET[ self::QUERY ];
    if( isset( $_GET[ self::QUERY_TYPE ] ) ){
    $args[ self::QUERY_TYPE ] = $_GET[ self::QUERY_TYPE ];
    }
    }
    if( isset( $_GET[ self::ORDER_BY ] ) ){
    $args[ self::ORDER_BY ] = $_GET[ self::ORDER_BY ];
    }
    if( isset( $_GET[ self::SAFE_SEARCH ] ) ){
    $args[ self::SAFE_SEARCH ] = $_GET[ self::SAFE_SEARCH ];
    }
    if( isset( $_GET[ self::AUTHOR ] ) ){
    $args[ self::AUTHOR ] = $_GET[ self::AUTHOR ];
    }
    if( isset( $args[ self::QUERY ] ) ){ // This is a search
    echo $this->doSearch( $args );
    }
    }

    /**
    * Perform the search with given arguments
    *
    * @author Michael Robinson
    * @param unknown_type $args
    */
    function doSearch( $args=Array() )
    {
    $uri = '';
    $params = Array();

    // USER
    if( isset( $args[ self::QUERY_TYPE ] ) && self::QUERY_TYPE_USER == $args[ self::QUERY_TYPE ] ){
    return $this->generateStandardPlaylist( $this->getUserUploads( $args[ self::QUERY ] ) );
    }
    // NORMAL SEARCH WITH PARAMS
    else{
    $query = $this->newVideoQuery();
    if( isset( $args[ self::ORDER_BY ] ) ){
    $query->setOrderby( $args[ self::ORDER_BY ] );
    }
    if( isset( $args[ self::SAFE_SEARCH ] ) ){
    $query->setSafeSearch( $args[ self::SAFE_SEARCH ] );
    }
    if( isset( $args[ self::AUTHOR ] ) ){
    $query->setAuthor( $args[ self::AUTHOR ] );
    }
    $query->setVideoQuery( $args[ self::QUERY ] );

    return $this->generateStandardPlaylist( $this->getVideoFeed( $query->getQueryUrl( 2 ) ) );
    }

    }

    /**
    * Prints a video feed in the format expected by WiiMC
    *
    * [playlist]
    *
    * File1=http://www.youtube.com/watch?v=l9gPGYqpAuA
    * Title1=HD Starcraft 2 BoxeR v Set
    * Length1=-1
    *
    * File2=http://www.youtube.com/watch?v=cmD5b85x_rw
    * Title2=HD Starcraft 2 IdrA v Ddoro
    * Length2=-1
    *
    * ( ... )
    *
    * @author Michael Robinson - [email protected] Copyright (c) ECPod, 2010
    * @param $videoFeed
    */
    function generateStandardPlaylist( $videoFeed )
    {
    $playlist = '';
    $len = sizeof( $videoFeed );
    $playlist .= self::PLAYLIST_HEAD . "nn";
    $i = 1;
    foreach( $videoFeed as $videoEntry ){
    $playlist .= "File$i=http://www.youtube.com/watch?v=" . $videoEntry->getVideoId() . "n";
    $playlist .= "Title$i=" . $videoEntry->getVideoTitle() . "n";
    $playlist .= "Length$i=" . ( ( !is_null( $videoEntry->getVideoDuration() ) ) ? $videoEntry->getVideoDuration() : '-1' ) . "nn";
    $i++;
    }
    return $playlist;
    }

    }

    $wiiMcPlaylistRetriever = new wiiMcPlaylistRetriever();

    ?>
    #27622
    cadbusca
    Participant

    Thanks for the reply. I’ll study it further.

    Just FYI, I see nothing in the WIIMC code (fileop.cpp/parseplxplaylist as attached) that would handle your snippet.
    WIIMC is looking for attribute= ….=value pairs, where the valid attributes are “type”,”name”,”url”,”thumb”, and “processor” , The values for “type” are “video”,”audio”,”playlist”,”search” and folder, the value for url is the http address, the value for name is the displayname, and the value for thumb is the address of the thumbnail image as currently used by Navi, and WIIMC uses these values to build its internal playlist.

    I tried your search on HDStarcraft and the result is certainly scrambled. Using my “Sort Playlists” (by name) option though worked nicely to give it some order: eg:

    HD Starcraft 2 Boxer v FruitDealer g1 p1/2
    HD Starcraft 2 Boxer v FruitDealer g1 p2/2
    HD Starcraft 2 Boxer v FruitDealer g2 p1/2
    HD Starcraft 2 Boxer v FruitDealer g2 p2/2

    and my “Autoplay Next YouTube” option played thru this ordered list without interuption. Kinda cool.
    Now if I could add the captions!

    Just saw your new post on “pagesof interest” so looks like you have a solution for now.

    Edit: Perhaps I misunderstood your snippet..is that what wiimc.org gets back from a yt search and then it translates it and sends the correct attribute,value pairs to the WIIMC program?

    #27623
    stzh
    Participant

    Yah I was just interested in hacking something together that would give me a little more control over the playlists retrieved from Youtube, I haven’t looked at any of the WiiMC source 🙂

    #27624
    stzh
    Participant

    @jhb50 wrote:

    … my “Autoplay Next YouTube” option played thru this ordered list without interuption. Kinda cool.
    Now if I could add the captions!

    Unfortunately I haven’t had time to compile a version of WiiMC with your additions 🙁

    @jbh50 wrote:

    Edit: Perhaps I misunderstood your snippet..is that what wiimc.org gets back from a yt search and then it translates it and sends the correct attribute,value pairs to the WIIMC program?

    The snippet:

    [playlist]

    File1=http://www.youtube.com/watch?v=l9gPGYqpAuA
    Title1=HD Starcraft 2 BoxeR v Set
    Length1=-1

    Is the format accepted by WiiMC’s online media…

    What I mean by this is:

    One makes a ‘playlist’ in the onlinemedia.xml file, i.e.:

    When one then clicks on this entry in Online Media, I assume WiiMC makes a GET request to the addr and expects a certain format to be returned. In the case of Youtube, I discovered that the format it requires is what I posted above.

    I have no idea what WiiMC does with it then, I’m not delving into C++. I guess it reads the list and extracts whatever parts it finds useful, then creates a list of objects that are then displayed as the clickable “playlist” that we see on our TV’s.

    @jbh50 wrote:

    WIIMC is looking for attribute= ….=value pairs, where the valid attributes are “type”,”name”,”url”,”thumb”, and “processor” , The values for “type” are “video”,”audio”,”playlist”,”search” and folder, the value for url is the http address, the value for name is the displayname, and the value for thumb is the address of the thumbnail image as currently used by Navi, and WIIMC uses these values to build its internal playlist.

    I know nothing of what goes on inside WiiMC.

    Do you think you could create a handler for a custom type? Or modify the [playlist] type to accept an url to a video’s captions? I can provide a PHP file / class to request and spit out any Youtube information you desire, in whatever format.

    #27625
    cadbusca
    Participant

    Lets work on this. Please see my pm.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Help and Support’ is closed to new topics and replies.

Login

Lost Password