Support for WebM

NodeBB Plugins
  • So I made this yesterday, and thought someone on here might like it. I've added support for webm files via, takes an ordinary .gif file, and converts it into a webm file, you then take the URL of that file, put it on your forum. Instant chicken dinner.


    npm install nodebb-plugin-gfycat

    I'd like to support all .webm files, but I don't know how, so if someone wants to pull on my request, that would be great, github can be found here

    I'd also like for it to automatically convert .gifs posted to the forum into webm files via their API, but again, not entirely sure how to. 😆

    RIP .gif etc

  • Awesome!

  • Asking for help now more than anything. Basically I'm converting the iframe to use HTML5 Video tags, the unique thing about gfycat is the fallback methods, if it's not supported, it falls back to the .gif, the trouble is, I need to use the api to grab that data, now, I've forked @julian xkcd plugin and hacked it to pieces, it doesn't crash the forum (an achievement in my eyes for my first plugin that's not some regex), but I can't actually get the api to give me the information I need.

    Can anyone see anything specifically wrong with what I've got here:

    Any help would be great, means I can push an update to this plugin out just that little bit quicker. 🙂

    EDIT: I made it a seperate plugin because I don't fully understand github and branches yet. 😆

  • @a_5mith What's the problem you're experiencing?

  • @julian it just won't connect to the api. It's parsing the template file, but it's not getting the values from the api itself, so the page loads as {thing.otherthing} rather than the link it should be.

  • Ok I made some progress, I'm connected to the api, however the video code doesn't work.

    The code in the templates file is

    <div class="row">
    <!-- begin gfyItem -->
    <video width="640" height="320" poster="//{gfyItem.gfyId}-poster.jpg" style="display: block;" muted="muted" loop="" autoplay="" class="gfyVid" id="gfyVid1">
    <source type="video/webm" src="{gfyItem.webmUrl}" id="webmsource">
    <source type="video/mp4" src="{gfyItem.mp4Url}" id="mp4source">
    Not supported, please try the URL: <a href="{gfyItem.gifUrl}">{gfyItem.gifUrl}</a>.
    <!-- end gfyItem -->

    And what comes out, is

    <div class="row"><a href="Correct URL">Correct URL</a></div>

    So it's connecting, but there seems to be an issue with running the video aspect of this, it's definitely not my browsers as I'm using Canary & Firefox 30.0. So one of the two fallbacks should work. All I get in Chrome is ::before and ::after either side of the link.

Suggested Topics

  • 0 Votes
    7 Posts

    @pitaj Many thanks for your effort 🙏

    Okay so I just npm link'ed my plugin again so I thought some file will be updated. But they weren't.

    Here is my full source code of libary.js:

    'use strict'; /* NodeBB Basic Plugin Libraries */ const controllers = require('./lib/controllers'); const plugin = {}; /* Third Party Libraries */ const Discord = require("discord.js"); const fs = require("fs"); // Nodebb Discord Bot const config = JSON.parse(fs.readFileSync("./utils/config.json", "utf-8")); var client = new Discord.Client(); let debug = true; plugin.init = function (params, callback, client) { myDebug("nodebb-discord-bot-started"); callback(); }; function myDebug(msg){ if(debug){ console.log(msg); } } module.exports = plugin; 2021-01-12T10:46:19.318Z [4567/4689] - error: Error: ENOENT: no such file or directory, open './utils/config.json' at Object.openSync (fs.js:462:3) at Object.readFileSync (fs.js:364:35) at Object.<anonymous> (/home/ubuntu/nodebb-linked-modules/nodebb-plugin-makesmart-discord-bot/library.js:15:30) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.Plugins.requireLibrary (/home/ubuntu/nodebb/src/plugins/index.js:70:39)

    I tried it with path again:

    // Nodebb Discord Bot var configpath = path.join(__dirname, 'utils', 'config.json'); const config = JSON.parse(fs.readFileSync(configpath, "utf-8")); var client = new Discord.Client();

    an suddenly ... it worked! o.O

    2021-01-12T10:51:15.711Z [4567/4765] - info: [api] Adding 2 route(s) to `api/v3/plugins` 2021-01-12T10:51:15.889Z [4567/4765] - info: Routes added 2021-01-12T10:51:15.933Z [4567/4765] - info: NodeBB Ready 2021-01-12T10:51:15.943Z [4567/4765] - info: Enabling 'trust proxy' 2021-01-12T10:51:15.972Z [4567/4765] - info: NodeBB is now listening on:

    I think it was really because I ran npm link again. Funny.* I'm sorry. Most of the time, the problem is in front of the computer. 🙄

    But still a strange behavior in my opinion. Well ... Good to know for the future. @PitaJ as mentioned thank you for you effort. 🙏

    For any others having the same issue:

    Read the Stackoverflow Solution posted by @PitaJ right here If it still not work use npm link in ./nodebb again to refresh something in the plugin folder ...I dont know tbh ... 😄
  • NodeBB, now with GIF support!

    NodeBB Plugins
    9 Votes
    34 Posts


  • 0 Votes
    2 Posts

    meta.config contains settings from NodeBB itself. Plugins retrieve their own settings via the settings module on the client side.
    pls reference:

  • 7 Votes
    23 Posts

    @yariplus Thanks!

  • 0 Votes
    3 Posts

    awesome! thanks