YtLight: a lightweight YouTube Oneboxer

(Claus Strasburger) #1

Continuing the discussion from Brand new plugin interface:

So I made this plugin. It’s working fairly well in development, but I haven’t had time to deploy it on my production instance yet.

Basically this replaces the generic whitelist oneboxer for and with simple image embeds. Those images get a play button, so users know it’s a video. Once they click the image, the actual youtube player is loaded.
This is especially useful if you have topics with massive amounts of YouTube-Links, because loading those takes some time and crashes some older boxes – with this plugin, no more!

How it looks:

The code: Lightweight YouTube Oneboxer for Discourse. · GitHub

After installing the plugin, you should rebake all your posts.

# (Inside of the container)
root@forum:/$ rake posts:rebake # this will take a long time.

Note that you can omit the post rebaking, this will cause only new, edited, and manually rebaked posts to use the light embed.

(Erlend Sogge Heggen) #2

Always loved YouTube Lyte for WordPress. I’ve experienced hangups with multiple youtube embeds more times than I care to remember.

(Claus Strasburger) #3

My intention was to at some point also support other embeds, especially vimeo and soundcloud.
If anybody wants to add these before I get the chance to – please do! :smile:

(Neil Lalonde) #4

This is great! Thanks for sharing it here. :thumbsup:


Experiencing a bug using this on our forum. For some reason when posting a youtube link, the post with have a ) right next to the embedded video. You can see what I mean here: Key Music Fan Covers - Key Fanworks - Kazamatsuri Forum

(Kane York) #6

In addition to that, the full player is loaded, not the clickthrough preloader.

In other words, it’s broken @cfstras

(Vikhyat Korrapati) #7

I don’t think the “)” next to embedded videos is caused by this plugin, I’m also seeing it and I’m not using this plugin. Also see:

(Claus Strasburger) #8

It seems it’s broken in the latest build. I’ll try to track it down.

(Claus Strasburger) #9

Would you look at that! it’s in youtube’s OEmbed code.

{ "stuff": "...",
"html": "\u003ciframe width=\"459\" height=\"344\" src=\"http:\/\/\/embed\/9b-aVDy6JfQ?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e)", // <-- there!

(Vikhyat Korrapati) #10

That’s pretty weird, though if this gets merged it won’t be an issue for most Youtube video embeds. :wink:

(nXqd) #11

anyone still gets this ytlight plugin working. It seems that the part to override youtube onebox engine doesn’t work any more. I have checked the latest code from Onebox engine of onebox gem .

(Jeff Atwood) #12

@eviltrout maybe we should just absorb this as the default YouTube oneboxer?

(Claus Strasburger) #13

For the time being, I updated the plugin to override the new oneboxer engine (careful, it’s pretty hacky):

Also, I added support for timed URLs, that is those who have a little &t=1m2s parameter to specify the starting time.

To update (as always, make backups beforehand):

$ cd plugins/ytlight && git pull && cd ../..
$ rake assets:precompile posts:rebake # get some coffee
$ # restart services now

(Robin Ward) #14

I don’t think we can put it into the onebox gem because it needs extra Javascript to work, but I support making it easier to overwrite the default gem’s behavior and including this as standard!


Seems to be back to broken, sadly, or at least I can’t see any effect from having it enabled.

(Claus Strasburger) #16

Are you sure? It works for me on the latest trunk (23ed5e0).

Be sure to run rake posts:rebake to convert old posts. Warning: This takes long if your forum is big.

(Jacob) #17

Is this still working? I ran rake posts:rebake and it doesn’t seem to be working.

(Claus Strasburger) #18

Still working for me (discourse 198fc3d, ytlight f456ac5).

Have you restarted your unicorn/thin/xyz after rebaking?
If yes, then could you provide me with some youtube-urls that are not converting? Not all possible URLs are covered by the current regex.

(Claus Strasburger) #19

The lazyYT-plugin that @techAPJ added recently broke this plugin :slight_smile:
Because I really need the feature of having videos start at a certain time in, I took the time to remove the ugly monkey patching and use the priority property instead.

For anyone having broken (or not oneboxed) youtube links:

Please update the plugin (using /admin/docker or by running git pull in the ytlight directory), then run this in the docker container (./launcher ssh app):

redis-cli flushall  # clear your cache
rake posts:rebake

(to anyone listening: is simply wiping out redis a good idea?)

(Jeff Atwood) #20

Shouldn’t the lazyYT plugin replace this one, don’t they do the same thing? Did we miss some basic functionality?