Advertisement:

Author Topic: Yet Another YouTube BBCode Tag  (Read 53582 times)

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Yet Another YouTube BBCode Tag
« on: December 10, 2014, 06:09:01 PM »
Link to Mod


YET ANOTHER YOUTUBE BBCODE TAG v4.3
By Dougiefresh -> Link to Mod


Introduction
This modification adds a BBCode to the forum that shows a YouTube video in your post.

These BBCode takes these forms:
Code: [Select]
[youtube]{youtube link}[/youtube]
[youtube width=x height=y]{youtube link}[/youtube]
[yt]{youtube ID}[/yt]
[yt {parameters}]{youtube ID}[/yt]
[yt_user]{username}[/yt_user]
[yt_user {parameters}]{username}[/yt_user]
[yt_search]{search query}[/yt_search]
[yt_search {parameters}]{search query}[/yt_search]
where width and height is specified by x and y.  If width and height aren't specified, width is 100% of the post display area and height in a 16:9 ratio to the width.

The yt_user bbcode will show videos by the specified YouTube username.

The yt_search bbcode will show videos matching the provided search phrase.

This mod should be able to display a valid YouTube video when passing URLs.  For example, all of the following will display the YouTube video at http://www.youtube.com/v/fA4cphzsjn8.
Quote
For YouTube Videos:
fA4cphzsjn8
http://www.youtube.com/fA4cphzsjn8
http://www.youtube.com/embed/fA4cphzsjn8
http://www.youtube.com/embed?v=fA4cphzsjn8
http://www.youtube.com/embed?feature=player_embedded&v=fA4cphzsjn8
http://www.youtube.com/watch?v=fA4cphzsjn8
http://www.youtube.com/v/fA4cphzsjn8
http://www.youtube.com/e/fA4cphzsjn8
http://www.youtube.com/?v=fA4cphzsjn8
http://www.youtube.com/user/username#p/u/11/fA4cphzsjn8
http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/fA4cphzsjn8
http://www.youtube.com/watch?feature=player_embedded&v=fA4cphzsjn8
http://www.youtube.com/?feature=player_embedded&v=fA4cphzsjn8

For YouTube PlayLists:
PL55713C70BA91BD6E
PLquckZj9TVRFKWqM6LJI4a_dgvN48jZGk
http://www.youtube.com/e/PL55713C70BA91BD6E
http://www.youtube.com/p/PL55713C70BA91BD6E
http://www.youtube.com/embed/PL55713C70BA91BD6E
http://www.youtube.com/embed?list=PL55713C70BA91BD6E
http://www.youtube.com/embed?feature=player_embedded&list=PL55713C70BA91BD6E
http://www.youtube.com/watch?v=OPf0YbXqDm0&list=PL55713C70BA91BD6E
http://www.youtube.com/?list=PL55713C70BA91BD6E
http://www.youtube.com/?feature=player_embedded&list=PL55713C70BA91BD6E
https://www.youtube.com/embed/videoseries?list=PLquckZj9TVRFKWqM6LJI4a_dgvN48jZGk
https://www.youtube.com/watch?v=Ni4ZclaiOtY&list=PLquckZj9TVRFKWqM6LJI4a_dgvN48jZGk
Substituting http://youtube.com, http://www.youtube-nocookies.com, http://youtu.be, and http://www.youtu.be also works.  https:// works instead of http://.  Please note any other parameters specified in the URL are ignored.

Optional parameters and values for all YouTube bbcodes are:
o width = Specifies the width of the iframe area.
o height = Specifies the height of the iframe area.
o start = Specifies how far into the video to start at.  Valid formats: "Seconds" or "Minutes:Seconds"
o end = Specifies how far into the video to stop at.  Valid formats: "Seconds" or "Minutes:Seconds"
o autoplay = 1, yes, on or true
o color = red or white
o theme = dark or light
o loop = 1, yes, on or true
o controls = 0, no, off, hide or false
o showinfo = 0, no, off, hide or false
o privacy = 1, yes, on or true

Profile Settings
There is a new option under Profile => Look and Layout called Show YouTube videos as a link.  Checking this box makes the mod create links instead of embedded videos in your post.

Admin Settings
This BBCode may be disabled by going into the Admin => Forum => Posts and Topics => Bulletin Board Code and unchecking the bbcodes you don't want to use.  You may also be uninstall this mod in order to disable it.

Related Discussions
o Adding option to stop mod from displaying YouTube video's as a video
o Youtube I.D parsing for new URL formats
o Need help with a Regular Expression for YouTube links....

Extra Credits Go Out To:
o Sapozhnik for code assistance
o karavan2 for providing code assistance
o kelvincool for Regular Expression assistance

Compatibility Notes
This mod was tested on SMF 2.0.10, but should work on SMF 2.1 Beta 3, as well as SMF 2.0 and up.  SMF 2.1 Beta 2 and SMF 1.x will not be supported.

Changelog
The changelog has been removed and can be seen at XPtsp.com.

License
Copyright (c) 2015 - 2017, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
« Last Edit: January 19, 2015, 09:50:28 AM by dougiefresh »
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #1 on: December 10, 2014, 06:37:12 PM »
Uploaded v1.1 - December 10th, 2014
o Added button for the bbcode.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #2 on: December 11, 2014, 04:18:48 AM »
Uploaded v1.2 - December 11th, 2014
o Fixed incorrect strings added by the mod.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline lordrene

  • Semi-Newbie
  • *
  • Posts: 79
Re: Yet Another YouTube BBCode Tag
« Reply #3 on: December 12, 2014, 04:15:06 AM »
Uploaded v1.2 - December 11th, 2014
o Fixed incorrect strings added by the mod.
I have the default 2.9 theme and when I try to install the mod, It give me this error

kat

  • Guest
Re: Yet Another YouTube BBCode Tag
« Reply #4 on: December 12, 2014, 06:12:56 AM »
http://wiki.simplemachines.org/smf/Error_in_mod_installation

The link might fail, a few times, coz the wiki's crap, at the moment, for some reason. Keep trying, though, and it'll load, eventually.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #5 on: December 12, 2014, 08:26:43 AM »
Uploaded v1.2 - December 11th, 2014
o Fixed incorrect strings added by the mod.
I have the default 2.9 theme and when I try to install the mod, It give me this error

Okay, these lines have to do with the parsers' ability to accept only the youtube bbcode (and contents) as the only content in the post.  In other words, you put this in your post:
Code: [Select]
[youtube]{some id here}[/youtube]and that's all and the editor will accept it.  If you have another mod that makes the same alteration to these areas, then you should be fine skipping those operations.  Although, I find it weird that the first operation works and the second doesn't.....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline NekoJonez

  • Full Member
  • ***
  • Posts: 501
  • Gender: Male
  • Stuff
    • @NekoJonez on Twitter
    • My blog
Re: Yet Another YouTube BBCode Tag
« Reply #6 on: December 16, 2014, 06:31:22 AM »
Does this mod display "link invalid" when it's actually invalid?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #7 on: December 16, 2014, 04:48:36 PM »
At present time, entering an invalid link only gets you a blank square....  I'll figure out something to make this work correctly for that situation....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #8 on: December 17, 2014, 06:44:22 PM »
Uploaded v1.3 - December 17th, 2014
o Rewrote mod to use one validation function for all bbcodes forms in this mod.
o Modified code to return "Invalid YouTube Link" if the link isn't valid...

Does this mod display "link invalid" when it's actually invalid?
@NekoJonez: This update provides this additional functionality.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #9 on: December 19, 2014, 08:11:23 PM »
Uploaded v1.4 - December 19th, 2014
o Fixed typo that resulted in errors being logged in the admin panel...
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline NekoJonez

  • Full Member
  • ***
  • Posts: 501
  • Gender: Male
  • Stuff
    • @NekoJonez on Twitter
    • My blog
Re: Yet Another YouTube BBCode Tag
« Reply #10 on: December 21, 2014, 04:58:38 PM »
Awesome, my next site update will replace the mod I had with this one :)
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Offline DJ Omnimaga

  • Jr. Member
  • **
  • Posts: 160
  • Gender: Male
  • CodeWalrus founder & retired Omnimaga founder
    • DJOmnimaga.Music on Facebook
    • @DJOmnimaga on Twitter
    • CodeWalrus
Re: Yet Another YouTube BBCode Tag
« Reply #11 on: December 27, 2014, 12:26:37 AM »
Does this support https links or just http?

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline NekoJonez

  • Full Member
  • ***
  • Posts: 501
  • Gender: Male
  • Stuff
    • @NekoJonez on Twitter
    • My blog
Re: Yet Another YouTube BBCode Tag
« Reply #12 on: December 27, 2014, 09:30:10 AM »
Feature request: could you add an option for users so that when they have eg a slow internet they can load the vids as links?

This topic could help: http://www.simplemachines.org/community/index.php?topic=522345.msg3695157#msg3695157
« Last Edit: December 27, 2014, 09:44:23 AM by NekoJonez »
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #13 on: December 27, 2014, 07:02:09 PM »
Does this support https links or just http?
Yes, this mod also supports the https form of the YouTube links.

Feature request: could you add an option for users so that when they have eg a slow internet they can load the vids as links?

This topic could help: http://www.simplemachines.org/community/index.php?topic=522345.msg3695157#msg3695157
Yes, I can do that for you.  And thanks for the helpful link to the solution....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline NekoJonez

  • Full Member
  • ***
  • Posts: 501
  • Gender: Male
  • Stuff
    • @NekoJonez on Twitter
    • My blog
Re: Yet Another YouTube BBCode Tag
« Reply #14 on: December 28, 2014, 06:07:04 AM »
Awesome. I can't wait until you get the option working :D. Would mean a great deal to me.
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #15 on: December 28, 2014, 04:59:38 PM »
Uploaded v1.5 - December 28th, 2014
o Added yt bbcode, which uses same syntax as the youtube bbcode.
o Added option to disable the embedding of YouTube videos on a per-user basis.
o Modified to use link provided when YouTube bbcode is disabled.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline NekoJonez

  • Full Member
  • ***
  • Posts: 501
  • Gender: Male
  • Stuff
    • @NekoJonez on Twitter
    • My blog
Re: Yet Another YouTube BBCode Tag
« Reply #16 on: December 29, 2014, 09:37:52 AM »
Is there already a feature to install the picture of the button into other themes?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Offline NekoJonez

  • Full Member
  • ***
  • Posts: 501
  • Gender: Male
  • Stuff
    • @NekoJonez on Twitter
    • My blog
Re: Yet Another YouTube BBCode Tag
« Reply #17 on: December 29, 2014, 11:03:58 AM »
Bug report:

  • The mod doesn't look for other themes to place the img for the button in.
  • When v1.5 is installed, the bbc codes get messed up. I couldn't get color to work and ALL my url tags where displayed as links.
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #18 on: December 29, 2014, 05:59:11 PM »
  • The mod doesn't look for other themes to place the img for the button in.
I've got this bug report fixed for the next version....

  • When v1.5 is installed, the bbc codes get messed up. I couldn't get color to work and ALL my url tags where displayed as links.
Crap....  I messed up in the package-info.xml file and replace instead of after....  I've fixed this bug report for the next version....  Sorry about that!
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,246
    • XPtsp.com Community
Re: Yet Another YouTube BBCode Tag
« Reply #19 on: December 29, 2014, 06:02:08 PM »
Uploaded v1.6 - December 29th, 2014
o Fixed image install locations within package-info.xml.
o Replaced replace with after in install.xml for new code in v1.5...
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!