I started this project before the YouTube one was released, I'm totally not trying to reinvent the wheel here. >< However I continued the project because I designed it to be extensible to download from almost any website without having to make an entirely new extension.
Currently the only video sites I could figure out and implemented are YouTube.com and Break.com, if you know how to get the .flv from other sites, feel free to post how! (Or write the descriptor yourself and post that.)
The descriptor isn't very simple..sorry, I tried to make it as simple as I could. The basic idea is to take a value from the page, url, javascript, a different downloaded page, etc, and use regex to truncate it (if necessary) and plop it into the final URL for the flv. ie. newurl = data.replace(regex,url);
There's a lot of options for getting the data, which are all explained in the grabber.js file for those of you daring enough to make your own.
I will explain YouTube's descriptor here to help out though:
Firstly video is the array of descriptors.Code:video["*.youtube.com/watch"] = new Array( new Array("js:swfArgs['video_id']","js:swfArgs['t']"), new Array(/(.*)/,/(.*)/),"http://youtube.com/get_video?video_id=$1&t=$2", "silver","id:watch-vid-title");
*.youtube.com/watch is the url pattern to run this descriptor against the page (mini greasemonkey! O: ). It's excruciatingly limited and complexly built because it's an index. There is a thorough description in the .js file. But basically, the *. says it's active for all sub domains, the youtube.com says it's active on youtube.com (duh) the / says there's a specific directory this can only be run in, and watch is that directory.
The first array set are the objects, what isolates the data. You can have as many of these as necessary so long as you have a regex expression for each one (that's the second array set).
js:swfArgs['video_id'] js: denotes that we're looking at a javascrpt variable defined on the page for this data, swfArgs['video_id'] is the variable to look at. This returns the value of swfArgs['video_id']. I think you can figure out the second one.
Its matching regex is /(.*)/, which means "remember all" in regex, meaning we're going to be using the whole value in the url string.
http://youtube.com/get_video?video_id=$1&t=$2 is the url string, $1 and $2 are where the values retrieved from the data goes. $1 is the first one (js:swfArgs['video_id']) and $2 is the second (js:swfArgs['t']).
The last two are the graphical part of it, silver is the name of the button used, you can define more buttons in the buttons array, which is explained in the .js, and I won't do it here.
id:video_wrap is where it will place the button on the page, id: means video_wrap is the id of the DOM object we're appending the button child to. (Appending - which means it will be going to the end of that object, so if the swf flv player is in that same object, it will go below or to the right of the swf
flv player.)
If you have any questions, please ask. I'll be happy to help.
Download it here:
[Only registered and activated users can see links. ]
UPDATE 1.1:
* Added support for: blip.tv, clipshack.com, and four AO sites.
* Improved page download and custom function support
* Bug fix: Unable to renumber a $X number in a URL if it was at position 0 in the string.
* Bug fix: Added support for default object notation (name). Should have been added in first release..
* Bug fix: RegEx is unable to easily remove unmatched data on multiple lines. All newlines replaced in all returns.
* Bug fix: "body:" now returns the contents instead of the object.
* Post 1.1: Updated crx to be compatible with 3.0.189.0
* Post 1.1 Bug fix: Fixed button images not loading.


LinkBack URL
About LinkBacks



Reply With Quote

Thanks
