Advanced BBCode Box 3

Stripping YouTube's ?feature=player_embedded - Advanced BBCode Box 3

Stripping YouTube's ?feature=player_embedded

New postby baloo » Mon Dec 05, 2011 8:57 am

I noticed when my users cut and paste from a YouTube url, and the url has "?feature=player_embedded&" between watch and v=, the bbvideo code doesn't work.

If I go and manually edit their post to remove the ?feature=player_embedded, all is fine.

How can I get abbc3 to auto strip that code for me ?
baloo
Registered User
Posts: 70
Joined: Mon Feb 11, 2008 12:32 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby leviatan21 » Mon Dec 05, 2011 3:23 pm

Use the bbvideo bbcode instead the youtube
Excuse me for my poor English, I speak Spanish. | Image phpBB en Español
User avatar
leviatan21
Registered User
Posts: 2663
Joined: Fri Aug 10, 2007 7:22 am
Location: Buenos Aires, Argentina
Name: Gabriel
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby baloo » Tue Dec 06, 2011 5:06 am

leviatan21 wrote:Use the bbvideo bbcode instead the youtube


I'm pretty sure I said that I was using the bbvideo code in my first post.

Here's a screen shot of bbvideo failing with feature=player_embedded& but working without it.

bbvideo error.jpg
baloo
Registered User
Posts: 70
Joined: Mon Feb 11, 2008 12:32 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby VSE » Tue Dec 06, 2011 6:09 pm

Sorry but that URL is not even a proper youtube URL. In Youtube pages, the video always follows the ?, and those other parameters come after the & symbol.

We can not support wrongly created URLs.

The URL you posted should look like this:
http://www.youtube.com/watch?v=8N_tupPBtWQ&feature=player_embedded

Your users need to use well-formed youtube URLs for it to work. In fact they should always use the URL provided by the Share option on Youtube's page, which these days looks more like:
http://youtu.be/8N_tupPBtWQ
User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 3139
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby baloo » Tue Dec 06, 2011 11:39 pm

In fact they should always use the URL provided by the Share option on Youtube's page, which these days looks more like:
http://youtu.be/8N_tupPBtWQ


Thanks, that's an answer I can accept, that your Mod needs the URL from the share option. That's fine, but it's going to be a step backwards for my users as the previous BBCode allowed them to cut and paste the url they were at, use the share, or even just use the video ID for the code to work.

For that reason I'll need to find a way to either override your youtube bbcode so my board functions again or remove your Mod completely, which is a shame.

VSE wrote:Sorry but that URL is not even a proper youtube URL. In Youtube pages, the video always follows the ?, and those other parameters come after the & symbol.

We can not support wrongly created URLs.

The URL you posted should look like this:
http://www.youtube.com/watch?v=8N_tupPBtWQ&feature=player_embedded

Your users need to use well-formed youtube URLs for it to work.


The rest of your answer is rubbish. A quick scan of my posts and there are many such URLs from YouTube. People don't make up their own URL, they cut and paste from YouTube's site. If the URL works, and it's what's displayed at the YouTube site when they go to watch a video, how can you say the URL is not a proper YouTube URL ?

I'm fine if you tell me your Mod can't handle all the different format a YouTube URL can take, but don't try and tell me it's YouTube's or my users fault that you Mod fails with certain URL structures.
baloo
Registered User
Posts: 70
Joined: Mon Feb 11, 2008 12:32 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby VSE » Wed Dec 07, 2011 12:31 am

Go to Youtube. Click any video. The link is always as I described.

http://www.google.com/support/forum/p/y ... 92f0&hl=en
http://www.raisedeyebrow.com/blog/2011/ ... re-update/

baloo wrote:If the URL works, and it's what's displayed at the YouTube site when they go to watch a video, how can you say the URL is not a proper YouTube URL ?

Because Youtube is designed to parse their own URLs in all combinations users may try to throw at them, even when they are not formatted the way Youtube defaults. That is not our responsibility. The responsibility of this MOD is to only work on correctly formatted URLs for any BBvideo from any of the websites it support.
User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 3139
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby baloo » Wed Dec 07, 2011 1:21 am

VSE wrote:Go to Youtube. Click any video. The link is always as I described.

http://www.google.com/support/forum/p/y ... 92f0&hl=en
http://www.raisedeyebrow.com/blog/2011/ ... re-update/

Because Youtube is designed to parse their own URLs in all combinations users may try to throw at them, even when they are not formatted the way Youtube defaults.


Again, I doubt my members are creating their own URLs, they are copying and pasting from their browsers.

That is not our responsibility. The responsibility of this MOD is to only work on correctly formatted URLs for any BBvideo from any of the websites it support.


Fine, thank you for sharing your stance on this and what you feel your Mod should cater for. That is completely your decision and I have no issues with that.

I though will have to go back to the old YouTube BBCode I had, which is about 3 years old, that worked with any combination of YouTube URL as well as only the video ID. While the rest of your Mod is a big hit on my site, the youtube issue is causing a lot of grief so I'll need to roll back.
baloo
Registered User
Posts: 70
Joined: Mon Feb 11, 2008 12:32 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby baloo » Wed Dec 07, 2011 3:34 am

BTW, I tracked down where that format of the URL comes from. It's from YouTube.

If someone has embedded a YouTube clip and the user clicks on the YouTube icon to go to the YouTube site, the code is formatted as I described above.

You can test it from Facebook. It's hardly a rare youtube url format.
baloo
Registered User
Posts: 70
Joined: Mon Feb 11, 2008 12:32 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby VSE » Wed Dec 07, 2011 9:02 pm

baloo wrote:BTW, I tracked down where that format of the URL comes from. It's from YouTube.

If someone has embedded a YouTube clip and the user clicks on the YouTube icon to go to the YouTube site, the code is formatted as I described above.

You can test it from Facebook. It's hardly a rare youtube url format.

I just tried exactly what you said.. Went to Facebook, clicked on a posted Youtube, and it created the link exactly as I described - this is the actual link:

Code: Select all

http://www.youtube.com/watch?v=XyDAtfKKlOo&feature=player_embedded


Bottom line is every BBvideo option shows the user exactly what the URL should look like in the popup/wizard. As with any BBcode, it is the users responsibility to make sure they are using a bbcode correctly.
User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 3139
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby baloo » Wed Dec 07, 2011 11:25 pm

OK, fine. I'm trying to help you out here but you seem determined to not believe me. That's fine. Strange position to take as a developer but that's none of my business.

I've solved my problem by deleting your YouTube code and re-installing the one I had which works perfect with any youtube format you can throw at it.

That, for me, is the bottom line.
baloo
Registered User
Posts: 70
Joined: Mon Feb 11, 2008 12:32 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby ty_ger07 » Fri Sep 07, 2012 5:52 am

This may or may not help and I am no expert by any means. But I found a very easy way to remove the issue of ?feature=player_embedded from the URL prior to &v=. This is indeed a very real issue and is not the user's issue. Youtube scrambles the link like that some times when the user visits Youtube from an embedded video player in another site.

Remove the ?feature=player_embedded from the URL first:

Code: Select all

if (stripos($text, "www.youtube.com/watch?feature=player_embedded") !== false)
{
   $text = preg_replace('/feature=player_embedded&/','', $text);
}


Consider this URL:

Code: Select all

http://www.youtube.com/watch?feature=player_embedded&v=R3unPcJDbCc


Now using the preg_replace code I gave, the URL is restructured into this form:

Code: Select all

http://www.youtube.com/watch?v=R3unPcJDbCc


Very simple. Now his code advance bbcode box code can proceed like normal.
ty_ger07
Registered User
Posts: 30
Joined: Wed Jun 22, 2011 5:00 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby ty_ger07 » Fri Sep 07, 2012 6:07 am

This is what I use in includes/functions_content.php to clean up a youtube link.

Starting on line 625 of phpbb version 3.0.7-PL1:

Code: Select all

$url= htmlspecialchars($url);
$text= htmlspecialchars($text);
// if youtube link is detected, remove extra crap from link text
if (stripos($text, "www.youtube.com/watch?feature=player_embedded") !== false)
{
   $text = preg_replace('/feature=player_embedded&/','', $text);
}
if (stripos($text, "www.youtube.com/watch?v") !== false)
{
   $text = (strlen($text) > 42) ? substr($text, 0, 42) . '' : $text;
}


Your line numbers might be different in a newer version of phpbb.

That removes the ?feature=player_embedded from the URL first, and then cuts the URL down to 42 characters to remove any additional unnecessary variables which may be at the end of the URL.

That code would clean up a URL like this:

Code: Select all

http://www.youtube.com/watch?feature=player_embedded&v=R3unPcJDbCc&feature=g-logo-xit

and display it as this instead:

Code: Select all

http://www.youtube.com/watch?v=R3unPcJDbCc
ty_ger07
Registered User
Posts: 30
Joined: Wed Jun 22, 2011 5:00 pm
Contact:

Re: Stripping YouTube's ?feature=player_embedded

New postby VSE » Fri Sep 07, 2012 6:13 am

that's not really an ideal solution. But I have already addressed this type of issue and the fix will be in the next version of this MOD.
User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 3139
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact: