Irish SEO,  Marketing & Webmaster Discussion

 

Parsing youtube video id

This is a discussion on Parsing youtube video id within the Coding Help forums, part of the Webmaster Help category; Has anyone got any experience parsing the video id from youtube urls in php. ie. youtube.com/watch?v= R0BA-KviNO4 &feature=related Where the ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-07-2008, 03:17 PM
Coder
 
Join Date: Nov 2007
Posts: 56
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
johned will become famous soon enough
Default Parsing youtube video id

Has anyone got any experience parsing the video id from youtube urls in php.

ie.
youtube.com/watch?v=R0BA-KviNO4&feature=related

Where the red is the part I want.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 09-07-2008, 03:56 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 1,775
Nominated 2 Times in 1 Post
TOTW/F/M Award(s): 0
Forbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond repute
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

what language ?
__________________
Forbairt Media | Web Design & Development Galway / Dublin, Ireland - coming soon ... ( vague but descriptive isn't it )
Recent Work: Safari Club African Safari Holidays - South Africa Safaris
Other Stuff: FluffyLinkulator Rapid Inclusion Service Tools
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 04:01 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 1,775
Nominated 2 Times in 1 Post
TOTW/F/M Award(s): 0
Forbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond repute
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

actually judging on your selfmade cms ...

I'll assume php ?

Code:
$string = "youtube.com/watch?v=R0BA-KviNO4&feature=related";

preg_match('/v\=(.+)&/',$string,$matches);

echo $matches[1];
do a semi ok job for you ?
__________________
Forbairt Media | Web Design & Development Galway / Dublin, Ireland - coming soon ... ( vague but descriptive isn't it )
Recent Work: Safari Club African Safari Holidays - South Africa Safaris
Other Stuff: FluffyLinkulator Rapid Inclusion Service Tools
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 04:09 PM
Coder
 
Join Date: Nov 2007
Posts: 56
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
johned will become famous soon enough
Default

I just cracked it without regular expressions from a little googling.

Here is the code it allows you to enter the url of a youtube vid in to a form and the code processes the form to parse the video id and insert it in to an embed code with preset values.

PHP Code:
//parse the id from the url
$url $_POST['id'];
$vidparser parse_url($url);
parse_str($vidparser[query], $query);
$vidid = ($query['v']);
 
 
//get the video id in to the embed code
$content "<object width=\"290\" height=\"235\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$vidid."&hl=en&fs=1&rel=0\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/".$vidid."&hl=en&fs=1&rel=0\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"290\" height=\"235\"></embed></object>"
seems to work well! I wrote it to a text file for include..

cheers for your help..

Last edited by johned; 09-07-2008 at 04:13 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 09-07-2008, 04:35 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 1,775
Nominated 2 Times in 1 Post
TOTW/F/M Award(s): 0
Forbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond repute
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

ah fair enough I'd assumed it'd be part of a multiline post or something similar not just a URL you had
__________________
Forbairt Media | Web Design & Development Galway / Dublin, Ireland - coming soon ... ( vague but descriptive isn't it )
Recent Work: Safari Club African Safari Holidays - South Africa Safaris
Other Stuff: FluffyLinkulator Rapid Inclusion Service Tools
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 09-07-2008, 04:42 PM
Coder
 
Join Date: Nov 2007
Posts: 56
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
johned will become famous soon enough
Default

No probs just finished it now and i can use the form to send sizes etc to the embed code.. Just hope they dont change anything on there side now lol .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
parsing, video, youtube

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
IrishVids.com - New YouTube? decbohan22 General Chat 6 16-07-2008 04:46 PM
Youtube API (gdata) + Zend framework on shared hosting failsafe Coding Help 2 29-04-2008 10:18 AM
suggestions: youtube plugin for wordpress davidbehan Webmaster Discussion 1 17-10-2007 05:10 PM
YouTube encouraged homicide suspect to surrender, say police Busarus General Chat 0 21-12-2006 07:38 PM
Google buy Youtube Cormac General Chat 4 13-10-2006 09:25 PM


All times are GMT +1. The time now is 05:58 PM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0