Playing with YouTube feeds

This is a followup to my Simplepie post a while back. YouTube offers Atom feeds, great – you’d think. However the data that YouTube outputs in its Atom feeds is…a bit different to what you might expect from a standard RSS feed in that it contains a lot of escaped HTML. Essentially for each item’s descripton in the feed YouTube outputs something like the following:

<div style="font-size: 12px; margin: 3px 0px;"><span></span></div></td>
<td style="font-size: 11px; line-height: 1.4em; padding-left: 20px;             padding-top: 1px;" width="146" valign="top"><div><span style="color: #666666; font-size: 11px;">From:</span>
<a href="">YouTube</a></div>
<div><span style="color: #666666; font-size: 11px;">Views:</span>

Which is basically a div that contains a table and is pretty intrusive if included in it’s native form. A rough and ready solution to just getting the bits you want (or at least I want) is to grab each item’s description and echo it via the substr function, this function allows you to specify which parts of a string you want to echo. It did rely a little bit of counting characters and I’m sure that there are far more efficient ways of doing it but if you, say, wanted the screenshot of the video linked to the video’s location on YouTube then your substr function would look something like this:

<?php $description=$item->get_description(); ?>

<?php echo substr($description,113,145); ?>

Which essentially tells the function to starting echoing from character 114 in the string (the count, as always, starts from 0) and to echo out the 145 characters from that point – which is the portion of the string involved in referencing the video’s screenshot and location.

There are a few other ways I can immediately think of using this particular set of data, will post them when I get a minute.


To produce embedded videos from the Atom feed then something like this will work:

<?php $description=$item->get_description(); ?>

<iframe title=”YouTube video player” width=”480″ height=”390″ src=”<?php echo substr($description,155,11); ?>” frameborder=”0″ allowfullscreen></iframe>

European wi-fi/3G coverage – please advise!

Righty, this summer I will need access to the net whilst on the move in the following countries: Turkey, Bulgaria, Serbia, Hungary, Austria, Germany, Belgium and France. There is the possibility that I will be in hotels for some of the time so this may (or may not – would welcome hearing about people’s experiences) partly solve the issue, however for the main part I will be on the road with just my laptop (macbook).

I’ll be needing to upload relatively large videos, images and text several times a day, every day.

I’d really welcome some wisdom on the subject, if I bought a new phone (iPhone, HTC/Andriod thingy ec) would this help – or is the coverage a bit patchy. Is there something I can get/sort out with my laptop that’ll help – dongle or similar? The last resort is getting a BGAN unit but that is very expensive and not really feasible at this stage.

Would also welcome thoughts on methods of uploading – particularly video as I’ve had a few problems getting large files up onto youtube in the past.