Not Solved YouTube Shorts URLs
#1
Not Solved
Is there any way to enable the posting of YouTube Shorts URLs with the [video] tag on MyBB? 

I am aware that users can currently re-format the video URL, from: 

Quote:https://www.youtube.com/shorts/(Video Code)

to:

Quote:https://www.youtube.com/watch?v=(Video Code)

However, this isn't user-friendly - and doing this manually for every video would simply get annoying. I did attempt to create a MyCode to perform the above change automatically - but, no luck there (presumably, the [video] tag itself is parsed before any MyCodes are). 

So, is there anything I can do to make these URLs work automatically?
Reply
#2
Not Solved
you can use mycode and regular expression
Some thing Like this :
REGEX is :
(https?:\/\/www\.youtube\.com\/shorts\/([\w\-]+)(\S+)?$)
and replacement is
https://www.youtube.com/watch?v=$2
Reply
#3
Not Solved
Thanks Smile .

Like I said in my initial posts, my first experiments with MyCode didn't work. However, I did come up with something:

REGEX:
\[video=youtube-shorts\]http(s)?://(www\.)?youtube.com/shorts/(.*?)\[/video]

Replacement:
<iframe width="315" height="560" src="//www.youtube-nocookie.com/embed/$3" frameborder="0" allowfullscreen="true"></iframe>

Only slight annoyance is that "YouTube Shorts" doesn't show on the drop-down for the editor - but sadly, if I change 'video=youtube-shorts' to the plain 'video=youtube', the MyCode stops working (presumably because the [video] tag tries to process them as regular videos!).
Reply
#4
Not Solved
Update the following :
https://github.com/mybb/mybb/blob/7d69ba...1600-L1613

To:
			case "youtube":
				if(!empty($fragments[0]))
				{
					$id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123
				}
				elseif(!empty($input['v']))
				{
					$id = $input['v']; // http://www.youtube.com/watch?v=fds123
				}
                elseif(count($path) >= 3 && $path[1] == 'shorts')
                {
                    // Shorts video embed with URL like: https://youtube.com/shorts/fds123
                    $id = $path[2];
                }
				elseif(!empty($path[1]))
				{
					$id = $path[1]; // http://www.youtu.be/fds123
				}
				break;

This should allow users to use something like [video=youtube]https://youtube.com/shorts/fds123[/video]

Regards.

---
I had this tab open almost 2 moths before replying...
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)