Jump to content

Get youtube id from url...


ikin

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.