Quote:
Originally Posted by GreeceMonkey
I am usless at REGEX, I am trying to add a embed service for youtube hi def service.
All I want to be able to say is if the end of the URL finishes as 'fmt=18'
then embed the youtube video with the addition code of '&ap=%2526fmt%3D18' in the embed code.
I am trying to do what is in the this DOC
http://www.insideonlinevideo.com/200...tube-tests-hd/
I have got it to work, but the originak youtube filter is also being triggered as it matches as well and I end up with two embeded videos in the same post.
I am sure this is simple, but regex is not my strong point
At the moment I have my regex expresson as
[ http://]*[a-z]*?[\.]?youtube\.[a-z]*?/watch\?v=([A-Z0-9._%-]*)[&\w;=\+_\-]*[&fmt=18]
and my embed code as
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$p1&ap=%2526fmt%3D18"></param><embed src="http://www.youtube.com/v/$p1&ap=%2526fmt%3D18" type="application/x-shockwave-flash" width="425" height="350" wmode="transparent"></embed></object>
hope somebody can help me
Graham Mattingley
|
Here's what I tried, and it seems to be working perfectly on my forum.
Keep the original YouTube RegEx the way it was, as that definition will still convert any URL, even one with the
fmt=18 on the end. Instead, change the
embed code, and the embed code only. Add
&ap=%2526fmt%3D18 after the
$p1 in the value and src URLs. I highlighted them in red:
Code:
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$p1&ap=%2526fmt%3D18"></param><embed src="http://www.youtube.com/v/$p1&ap=%2526fmt%3D18" type="application/x-shockwave-flash" width="425" height="350" wmode="transparent"></embed></object>
Now test it out with these four URLs. The first two are the ones in the article with the skateboarding dog:
http://www.youtube.com/watch?v=CQzUsTFqtW0
http://www.youtube.com/watch?v=CQzUsTFqtW0&fmt=18
And these last two are a Barack Obama speech that is currently NOT available in HD but has the
fmt=18 on the end of one anyway.
http://www.youtube.com/watch?v=QW4sqy9iBDc
http://www.youtube.com/watch?v=QW4sqy9iBDc&fmt=18
What should happen when you post these four is that both instances of the skateboarding dog should have embedded in HD and both Barack Obama videos should have embedded as they would normally.
This means that you users don't even have to know if their video is available in HD, the embed code will do the work for them, and if it isn't it will embed normally. And even if they do post the URL with the extra set of number on the end, it will still work the same way. Test that out and let me know if it's working for you the way it is for me, and I'll add it to the next cycle of XML updates.