Good Question...
It's basically a two stage regex problem
1: identify what site is providing the movie as they sometimes have different embed codes using either a user selected drop down box or a regex statement with either the
preg_match or
strpos functions to search for a keyword like google,youtube, veehd etc...
see examples below
You Tube-
Code:
<object width="560" height="349">
<param name="movie" value="http://www.youtube-nocookie.com/v/KN5wo-NYLwU?version=3&hl=en_GB&rel=0">
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed src="http://www.youtube-nocookie.com/v/KN5wo-NYLwU?version=3&hl=en_GB&rel=0" type="application/x-shockwave-flash" width="560" height="349" allowscriptaccess="always" allowfullscreen="true"></embed>
Google Video-
Code:
<embed id=VideoPlayback src=http://video.google.com/googleplayer.swf?docid=428349265473317718&hl=en&fs=true style=width:400px;height:326px allowFullScreen=true allowScriptAccess=always type=application/x-shockwave-flash> </embed>
2:Once you know the provider a second regex statement using
preg_match can made to extract the file name for that provider,
KN5wo-NYLwU for the YouTube example and
428349265473317718 for the Google.
Once you have that then you can insert the file ID back into a stored embed string for that provider that you keep on your web server and write it into the page.
Doing it this way also means every video submitted would be the same size so as not to mess up any page layout. Plus you have control over what sites users can upload the embed codes for, otherwise you could be providing access to pornography or pirated movies on your site.