Hi,
the function emvideo_dailymotion_extract() doesn't work when several IDs are passed to the URL.
Example :
http://www.dailymotion.com/playlist/xxxxxx_example_title_playlist/video/yyyyyy_example_title_video
I used preg_match_all() function instead of preg_match(), and used array_pop() to return the last value.
Here is the code :
function emvideo_dailymotion_extract($embed = '') {
if (preg_match('@dailymotion\.com/swf/([^"\&]+)@i', $embed, $matches)) {
return $matches[1];
}
if (preg_match('@dailymotion\.com@i', $embed, $matches)) {
if (preg_match_all('@/([^/_]+)_@i', $embed, $matches)) {
$id = array_pop($matches[1]);
if (!is_array($id) && $id != NULL) {
return $id;
}
}
}
return array();
}
This code returns the last ID in the URL. Perhaps it would be better to catch "videos/xxxxxx_" instead...
Regards,
Nicolas Bourdial.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | dailymotion.patch | 759 bytes | robloach |
Comments
Comment #1
robloachDo you have some URLs to test this out on? Not sure what error your running into.
Comment #2
nbourdial commentedhere is an example : http://www.dailymotion.com/playlist/xuo9l_TOULOUSEFOOTBALLCLUB_news/vide...
the first ID is the playlist's ID.
Comment #3
aaron commentedseems like catching for videos/xyz123 would be better; that's a fairly simple regex pattern.
Comment #4
Gabriel R. commentedYes, I've noticed this as well. Another URL examples is
http://www.dailymotion.com/relevance/search/beyonce+dreams/video/x9zmoq_... Don't hold the content of that search against me :-)