Mobile YouTube Extension - Hyphen in link problem

dcoursen
13 years, 7 months ago
Of course... Kudos to the application. Took awhile to implement and get it working, but worth it!
I am having a problem with you mobile YouTube extension. When the YouTube link contains a hyphen it appears the link is being rewritten incorrectly, stopping at the hyphen. So the link for video: a1FpEPDd-Lo is converted to video: a1FpEPDd and This link does not work when clicked the video can not be found.

Here's the embed code I'm using in my K2 tab of the site using Joomla Version:1.5.15 :

<object width="560" height="349"><param name="movie" value="www.youtube.com/v/a1FpEPDd-Lo?fs=1&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="/www.youtube.com/v/a1FpEPDd-Lo?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" width="560" height="349" allowscriptaccess="always" allowfullscreen="true"></embed></object>

Using an android phone if you navigate to this via the link... it says video a1FpEPDd can not be found.

If you change the embed code to include a link to a video that does not have the hyphen... it works wonderfully. My issue is with over 300 videos, we're sure to have others with a hyphen.

Can anyone provide some suggestions on how to fix this.

The website is www.thegardencorner.com/passion-codes.html (category view of videos - these are for instore QR Codes, so they are not on a menu.

The link to the specific video causing the issue is.... www.thegardencorner.com/passion-codes/item/678-slugo.html

This one is working: www.thegardencorner.com/passion-codes/item/677-lime.html

Thanks is advance for your time.
dcoursen
13 years, 7 months ago
It appears to have been a problem with the regex: In the plugins/mobile/youtube/youtube.php the code....

____________________________________________________

	function youtube_object($matches)
{
static $youtube_pattern_object_1 = '#^.*?<param name="movie" value="http://(?:www\.)?youtube\.com/(?:watch\?v=|v/)(\w+).*?$#is';
static $youtube_pattern_object_2 = '#^.*?<param value="http://(?:www\.)?youtube\.com/(?:watch\?v=|v/)(\w+)[^"]*?" name="movie".*?$#is';
$text = $matches[0];
$text = preg_replace($youtube_pattern_object_1, $this->youtube_replacement, $text);
$text = preg_replace($youtube_pattern_object_2, $this->youtube_replacement, $text);
return $text;
}
 


Should be replaced with:

	function youtube_object($matches)
{
static $youtube_pattern_object_1 = '#^.*?<param name="movie" value="http://(?:www\.)?youtube\.com/(?:watch\?v=|v/)([\w|\-]+).*?$#is';
static $youtube_pattern_object_2 = '#^.*?<param value="http://(?:www\.)?youtube\.com/(?:watch\?v=|v/)([\w|\-]+)[^"]*?" name="movie".*?$#is';
$text = $matches[0];
$text = preg_replace($youtube_pattern_object_1, $this->youtube_replacement, $text);
$text = preg_replace($youtube_pattern_object_2, $this->youtube_replacement, $text);
return $text;
}


This will allow you to have hyphens within your video name. Hope it helps.... it did me..
dryabov
13 years, 7 months ago
Thanks a lot. Unfortunately, I've never got hyphen in youtube links, so I expected that [\w] is sufficient.

PS. I'm going to replace it by [0-9A-Za-z_\-] to avoid any issues.

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.