View Single Post
  #1249  
Old 05-17-2008, 11:19 PM
Digital Jedi's Avatar
Digital Jedi Digital Jedi is offline
 
Join Date: Oct 2006
Location: PopCulturalReferenceLand
Posts: 5,171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GreeceMonkey View Post
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.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01092 seconds
  • Memory Usage 1,785KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete