ikin Posted November 18, 2010 Share Posted November 18, 2010 Well I'm trying to learn regex so I can use it on my bot but I can't seem to do it right... I was using http://www.spaweditor.com/scripts/regex/index.php for a while and came up with this: /watch\?v=(.*)/ To parse: iIp7OnHXBlo out of But it only ended taking the new word to like if I had Cake is good http://www.youtube.com/watch?v=iIp7OnHXBlo do you like cake? it would take with the iIp7OnHXBlo do you like cake? instead of only the iIp7OnHXBlo So yea I need some help... Code: if (preg_match('/watch\?v=(.*)/', $dh->getircTrailing()." ", $trackkeys)) { if ($trackkeys != "") { $feedURL = 'http://gdata.youtube.com/feeds/api/videos/' . $trackkey[1]; $entry = simplexml_load_file($feedURL); $video = parseVideoEntry($entry); $dh->reply("[Youtube} Title: {$video->title} | By: {$video->author} (uploaded on " . convert_tz($video->published, UTC) . ") | Duration: " . sprintf("%0.2f", $video->length / 60) . " | Views: {$video->viewCount} | Rating: {$video->rating}"); } } Link to comment https://forums.phpfreaks.com/topic/219111-get-youtube-id-from-url/ Share on other sites More sharing options...
ikin Posted November 18, 2010 Author Share Posted November 18, 2010 I'll found out that I can use /v=(\w*)/ To myself: Link to comment https://forums.phpfreaks.com/topic/219111-get-youtube-id-from-url/#findComment-1136270 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.