views:

134

answers:

3

I am wondering if there is a script similar to the facebook status update thing, What I mean, is when for ex. I paste a youtube/other video site/image/link it automatically detects the contents of the page and associates an embed code with it (if its a video)..

So I'm wondering if there is a ready script that has a large database of websites and can associate video site url's with embed codes.

I could actually do something like that by myself but the problem is that I want to support a lot of websites, like facebook does.

Please help me find a solution.

Thanks.

+2  A: 

You really wouldn't have to scan that large of a database. With videos, you could keep track of maybe the top three or so uploading sources (youtube, vimeo, metcafe...) and their embed codes.

As for images and links, those are pretty easy to detect and don't require any special embed code. By pretty easy, I mean very simple. Just use a simple regular expression to search for a link in their post.

If it's a picture, you can easily tell by looking at the file extension of the link (jpg, png, gif, etc.). If so, do whatever is proper to embed any old image. If it's just an ordinary old link (doesn't match any of your video sites, or doesn't end in a file extension for an image), just use the link itself.

The only marginally tricky part would be getting the unique embed codes for the video sites. But perhaps there is some external library/api that could do that small part for you (another answerer has provided has a proper API/pre-built library for this). However, images and links are mostly pretty simple.

EDIT It seems I misread your problem, and that you are only looking for pre-built libraries with video embed codes. In that case, the other answer is exactly what you want.

Justin L.
+3  A: 

Take a look at the Embedly API: http://api.embed.ly/ It gets the embed code for a lot of the popular video sites out there and also for some images sites. I highly recomend it, you can try it out here.

vitorbal
Thanks for the site!I am probably going to use that, but just another question,I can't download and host the code this site uses, right?It makes me very dependent on the site.. for ex. if its down I cant do anything..
Michael S.
Yes that is indeed a problem, but I've used it before and it has been very reliable so far.. alternatively you could use oohEmbed (http://oohembed.com/). oohEmbed doesn't support as many sites as embedly, but it is opensource so you can checkout their code at (http://code.google.com/p/oohembed/) and host it yourself, besides extending it as you see fit, etc.Hope this helps
vitorbal
Thanks for the reply! oohembed looks nice but I think i'll stick with embedly.. it has some sites i'd like to support.
Michael S.
No problem, good luck!
vitorbal
A: 

http://www.oembed.com/

josemimg