Re: extract youtube video id from embed script

2009-07-21 Thread Peter Boughton

The following code makes a couple of assumptions about the URL / id which are 
probably safe, but not guaranteed (that the ID will always be before an 
ampersand, and never contain any slashes).



cfsavecontent variable=Codeobject width=550 height=331param 
name=movie 
value=http://www.youtube.com/v/iNCsMTYkw1Mhl=enfs=1;/paramparam
name=allowFullScreen value=true/paramparam
name=allowscriptaccess value=always/paramembed 
src=http://www.youtube.com/v/iNCsMTYkw1Mhl=enfs=1;
type=application/x-shockwave-flash allowscriptaccess=always
allowfullscreen=true width=550 
height=331/embed/object/cfsavecontent

!---
INFO:
Since CF doesn't have a HtmlParse we need to escape ampersands for XML:
---
cfset Code = replace(Code,'','amp;','all')/

!---
INFO:
Convert Code to XML nodeset and locate src of embed tag.
---
cfset XmlData = XmlParse(Code) /
cfset EmbedSrc = XmlSearch(XmlData,'//embed/@src') /
cfset VideoUrl = EmbedSrc[1].XmlValue /

!---
INFO:
Locate Id by stripping away everything after the first  and everything 
before the last /
---
cfset VideoId = ListLast(ListFirst(VideoUrl,''),'/')/



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324761
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: extract youtube video id from embed script

2009-07-21 Thread Peter Boughton

It looks like the HoF display code is broken.

This line of code:
cfset Code = replace(Code,'','','all')/

Should have ' a m p ;' (without spaces) as the third argument.




~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324763
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


extract youtube video id from embed script

2009-07-20 Thread Mike Little

hey guys,

need some help with the following. how do i successfully extract just the video 
id from a typical youtube embed script? eg.

object width=550 height=331param name=movie 
value=http://www.youtube.com/v/iNCsMTYkw1Mhl=enfs=1;/paramparam 
name=allowFullScreen value=true/paramparam name=allowscriptaccess 
value=always/paramembed 
src=http://www.youtube.com/v/iNCsMTYkw1Mhl=enfs=1; 
type=application/x-shockwave-flash allowscriptaccess=always 
allowfullscreen=true width=550 height=331/embed/object

would return 'iNCsMTYkw1M'

any help would be greatly appreciated.
mike 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324706
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4