12.11TubeGripClient - Play Any Movie on YouTube in AS3 with your own player!
Hi Everyone,
as some of you might have noticed, KeepVid went downhill. I don't know exactly when, however I found an alternative: http://www.tubegrip.com. It works pretty well...
Here is a sample use of this library:
Actionscript:
-
public function startTest():void
-
{
-
_client = TubeGripClient.getInstance();
-
-
// this takes a url from YouTube they call Watch Urls.. basically, the url you get when you try
-
// to share a video with a friend...
-
_client.getFLVUrl("http://www.youtube.com/watch?v=WPzgGs_cHWo");
-
_client.addEventListener(TubeGripEvent.URL_READY, doUrlReady);
-
_client.addEventListener(TubeGripEvent.REQUEST_FAILED, doRequestFailed);
-
}
-
-
protected function doUrlReady(evt:TubeGripEvent):void
-
{
-
trace("urls are:");
-
trace("[flv] " + evt.flvUrl);
-
trace("[hd] " + evt.hdUrl);
-
trace("[hq] " + evt.hqUrl);
-
}
-
-
protected function doRequestFailed(evt:TubeGripEvent):void
-
{
-
trace("request failed.. for whatever reason");
-
}
This library uses the RESTProxy. The tricky part was, as always, extracting the useful information from the HTML returned by TubeGrip.
So I used the following Regular Expressions to do that:
Actionscript:
-
var flvFilter:RegExp = /href="(http:\/\/v[^"]+)" target="_blank"><b>Download Video<\/b>/g;
-
var hqFilter:RegExp = /href="(http:\/\/v[^"]+)" target="_blank"><b>Download High Quality Video<\/b>/g;
-
var hdFilter:RegExp = /href="(http:\/\/v[^"]+)" target="_blank"><b>Download HD Video<\/b>/g;
I used this really cool REGex Tester for tuning the regular expressions...
It was much easier to handle on TubeGrip than KeepVid; mind you.
Cheers,
Martin

Thanks martin, i just discovered your blog.. I credited you on my blog for the use of the date util class in AS3 , sorry for the mistake !
I’m currently working on a stream video player for my company,and they host videos on you tube , so i think your code will be of some great help !! Thanks !
December 21st, 2009 at 3:35 am
Hi Martin
Great Help indeed!
a bit embarrassing, i couldn’t get it to work though
i tried a few links from youtube
checked them manually on tubegrip
no success still
are there any other requirements besides connecting the Main class as the Document Class to a new FLA?
cheers
s
March 31st, 2010 at 1:54 pm
Is this a work in progress or functioning?
May 24th, 2010 at 2:41 pm