Youtube thumbnails



  • The youtube-lite plugin we're using tries to use some obsolete thumbnail images. This has been discussed elsewhere, but I didn't see a dedicated topic for it. But I have a pull request:

    Paging @ben_lubar ... if only notifications worked. :cry:



  • I've been playing around with the plugin. Firstly, it has the height hardcoded in the div that it makes, which the code later checks to see what it should do. But since it's hard coded...

    Now...if we don't do the API calls, we can let the thing become an iframe. And then it changes size based on the browser. We'd just need to constrain it, size-wise. I guess similar issues would apply to showing the thumbnail. Though honestly, since they're pretty standard, we probably don't need to use the API at all, unless we want to show the title, which the plugin doesn't currently do.

    It needs some additional updates to support a start time: update the regex for finding a youtube url and then using it to embed it in the markup.



  • @boomzilla said in Youtube thumbnails:

    unless we want to show the title, which the plugin doesn't currently do.

    Having the title before pressing play is handy, although not essential I guess if the thumbnail is there.



  • @loopback0 said in Youtube thumbnails:

    Having the title before pressing play is handy, although not essential I guess if the thumbnail is there.

    It's damn handy if your workplace firewall block youtube so the only thing you get are the thumbnail and the title



  • @boomzilla Do you want to embed videos in the preview as well?

    In library.js, replace the parse function with this:

    YoutubeLite.parse = function(data, callback) {
        if (data && typeof data === 'string') {
            // preview
            data = data.replace(regularUrl, embed);
        } else if (data && data.postData && data.postData.content) {
            // post
            data.postData.content = data.postData.content.replace(regularUrl, embed);
        }
        callback(null, data);
    };
    

    In plugin.json, add this to "hooks":

           { "hook": "filter:parse.raw", "method": "parse" },
    


  • @NedFodder That's awesome because I bet it totally re-implements the bug where it sends a network request to YouTube for literally every single keystroke.

    But I'm sure you've tested that, right? Because you wouldn't just shit-out code you hadn't tested at all.



  • @blakeyrat said in Youtube thumbnails:

    sends a network request to YouTube for literally every single keystroke.

    Ooh, yeah that's bad. I tested it by pasting a link and seeing the video show up in preview, didn't type anything after that. Mock me some more, I've earned it.



  • @NedFodder I'm not going to yell at you, but goddamned, I hope you don't call yourself a "software developer" in your career, because that's inexcusable shit. You didn't even BOTHER to test the ONE scenario that caused us to disable the preview in the first place. I mean come ON!



  • @blakeyrat said in Youtube thumbnails:

    I'm not going to yell at you, but goddamned, I hope you don't call yourself a "software developer" in your career, because that's inexcusable shit.

    Dude, STFU. He's testing and doing stuff and asking questions.



  • @NedFodder said in Youtube thumbnails:

    Do you want to embed videos in the preview as well?

    Ultimately, yes, I do. However...I have additional issues with the way this thing works. So...it makes the cooked use iframes. Then, it's designed to do a call in document onready or whatever using jQuery to get all of its iframes, do a youtube API call and update stuff on the client.

    Well, the properties aren't quite right, so your API key doesn't get transmitted correctly. This is actually a good thing, because otherwise you're giving your key out to anyone who views the page. :wtf:

    Eventually, all that stuff should be done server side, I think. Of course, we'd still have to solve the spam-the-youtube-api problem for previewing, but we'd end up with a cooked version with everything done right there, including titles and stuff. I haven't looked at a youtube heavy topic on mobile, but I imagine this stuff could be causing a noticeable delay there.



  • @boomzilla said in Youtube thumbnails:

    Of course, we'd still have to solve the spam-the-youtube-api problem for previewing

    LRU cache?



  • @ben_lubar Something like that. Of course, the first step is to get it working....



  • @boomzilla said in Youtube thumbnails:

    He's testing

    He admittedly did not test that code. If he had, he wouldn't have posted it, and then I wouldn't have posted that response you seem to object to so much.



  • @blakeyrat Bullshit.


  • sockdevs

    @ben_lubar that and probably a timeout to make requests to the youtube api at a maximum rate of..... say 2 requests/second while editing?

    pulling the number our ot my tail of course



  • @accalia If we have a LRU cache, it's very unlikely that someone editing a post will get multiple cache misses during one post writing action.



  • @accalia Or how about you just not call the API again if you've already fetched that link :thinking:



  • Or how about you wait like 6 weeks, which is about how long it takes to completely forget everything apparently, then propose we implement this exact same fucking broken code then even though it's still broken.



  • This is probably a dumb question, but why don't we just use the iframe 'API' that YouTube also offers?



  • @blakeyrat said in Youtube thumbnails:

    Or how about you wait like 6 weeks, which is about how long it takes to completely forget everything apparently, then propose we implement this exact same fucking broken code then even though it's still broken.

    If you're not going to even try to be productive, get out of this thread.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.