this post was submitted on 19 Dec 2024
68 points (98.6% liked)

Fediverse

28712 readers
73 users here now

A community to talk about the Fediverse and all it's related services using ActivityPub (Mastodon, Lemmy, KBin, etc).

If you wanted to get help with moderating your own community then head over to !moderators@lemmy.world!

Rules

Learn more at these websites: Join The Fediverse Wiki, Fediverse.info, Wikipedia Page, The Federation Info (Stats), FediDB (Stats), Sub Rehab (Reddit Migration), Search Lemmy

founded 2 years ago
MODERATORS
 

If you go to !videos@lemmy.world and scroll you'll see some of the posts have a youtube thumbnail image, but not all.

I wanna post YouTube videos, but no one seems to engage much without a thumbnail, which makes sense, but I'm not sure what would result in the post actually having a thumbnail

If anyone has advice or guidance I'd appreciate it :) Thanks!

EDIT: so far it seems like it's potentially a combination of what version of lemmy the posters account is running, and how that instance is configured...

all 34 comments
sorted by: hot top controversial new old
[–] andrew_s@piefed.social 18 points 3 days ago (2 children)

It depends on what youtube is willing to provide. It seems more likely to provide a thumbnail if you use a youtu.be link than a youtube.com link.

Instances running Lemmy from 0.19.4 onwards (I think) provide the option of providing a separate thumbnail manually, which is useful, but your instance is on 0.19.3.

[–] Cris_Color@lemmy.world 2 points 3 days ago

I tried again with a youtu.be link and unfortunately no dice, so it seems it might be an instance issue, I'm gonna go take a look at the videos comm and see if there's anyone on .world who posted and got a thumbnail. I might also try again from my .ee account

[–] Cris_Color@lemmy.world 1 points 3 days ago* (last edited 3 days ago)

Okay so it seems like the only people getting thumbnails on !videos@lemmy.world are from shitjustworks.

No dice on using my .ee account though, that didn't seem to result in a thumbnail either. But in the app I'm using, when on my .ee account there's a field to put in a thumbnail URL which is interesting

[–] hono4kami@slrpnk.net 11 points 3 days ago (3 children)

It's because Lemmy can't fetch YouTube thumbnails. I swear it used to fetch thumbnail and title automatically before, hmm

[–] flamingos@feddit.uk 12 points 3 days ago* (last edited 3 days ago) (2 children)

It's because YouTube puts a bunch of JavaScript at the start of the file (1MiB) before the opengraph tags and Lemmy only fetches the first 512 KiB (a fix was merged a couple days ago).

[–] hono4kami@slrpnk.net 6 points 3 days ago* (last edited 3 days ago) (1 children)

If you don't put a whopping 1MB of JavaScript in your website, you're doing web development wrong.

/s

[–] Enoril@jlai.lu 2 points 3 days ago

Don’t forget to add also the 2856 partners intrusive code lines and cookies to have a "better experience"

[–] p03locke@lemmy.dbzer0.com 1 points 2 days ago

I can fetch the damn thumbnail just fine. I have to do it on every YT post I submit.

Reddit can fetch thumbnails from hundreds of websites, all of them different, including a bunch of porn sites. Pretty sure they have to code each site to map out the right URL and tags to parse.

I know Lemmy is OSS, but I really wish it wasn't so slow on the uptake with these things.

[–] TehBamski@lemmy.world 7 points 3 days ago (1 children)

I can testify to this. I was there. I was there when Lemmy so valiantly fetched ye old YouTube thumbnails.

[–] limer@lemmy.dbzer0.com 4 points 3 days ago (1 children)

Uphill, in the snow, both ways

[–] TehBamski@lemmy.world 2 points 3 days ago

Into the depths of Moria and through Lothlórien forest.

[–] sundrei@lemmy.sdf.org 7 points 3 days ago (2 children)

I dunno, but it depends on the instance. Here's a screenshot from lemmus.org:

And here's the same community seen from lemmy.sdf.org:

[–] Cris_Color@lemmy.world 3 points 3 days ago

Interesting, so I guess maybe the reason shitjustsworks users posting on !videos@lemmy.world are showing up as thumbnails for me is because their instance is getting the thumbnail and that's federating to me on .world

[–] MelonYellow@lemmy.ca 2 points 3 days ago

Here it is from lemmy.ca (sorted by new):

[–] Skiluros@sh.itjust.works 6 points 3 days ago (1 children)

Instances running 0.19.5 (I think) allow manually adding a thumbnail.

I extract them from https://youtube-thumbnail-grabber.com/ and manually add them in.

Really annoying.

[–] treadful@lemmy.zip 2 points 3 days ago (1 children)

Or shift+right click on the unplayed video and copy image link to get the thumbnail.

I've been doing it manually because otherwise nobody watches it.

[–] Skiluros@sh.itjust.works 1 points 3 days ago

Will need to try this. Grabbing the thumbnail via an external site is annoying.

[–] hono4kami@slrpnk.net 5 points 3 days ago* (last edited 3 days ago) (2 children)

So I take a peek at the Lemmy's source code.

When you see a thumbnail and title of a URL (including YouTube video links) on Lemmy, what happens is that Lemmy server fetched the website HTML file and get the og:title and og:image (this convention is called OpenGraph protocol ^1) located inside <head> HTML tag.

For example, for this video https://www.youtube.com/watch?v=MbYuEEU5e50, the OpenGraph metadata inside the HTML looks like this:

<meta property="og:title" content="Flume - Lose It feat. Vic Mensa">
<meta property="og:image" content="https://i.ytimg.com/vi/MbYuEEU5e50/maxresdefault.jpg">

Try opening the "Create Post" page, then enter URL of a YouTube video. You might notice that a loading spinner will appear. During this, the frontend of Lemmy is actually creating a request to /api/v3/post/site_metadata?url=[insert your URL]. When the backend side of Lemmy receives the request from front end, it will run this code ^2 to fetch the HTML and parse it to find the OpenGraph metadata. If the metadata is found, the backend will return it to front end, and you willl see recommended title and the "Thumbnail URL" field should be filled.

In theory, this should work fine, regardless of any website. I personally tried to view the HTML code of a YouTube video and the HTML file indeed contains OpenGraph metadata.

But it doesn't for YouTube videos in Lemmy somehow. And I'm not sure.

I'm suspecting YouTube thought that Lemmy servers are bots and because of that instead of receiving the HTML file of a YouTube video, instead it received a HTML file of a captcha page. I think I'm gonna try contacting admins of my instance to see whether YouTube URL works or not.

[–] hono4kami@slrpnk.net 3 points 3 days ago* (last edited 3 days ago) (1 children)

Also, this is a good tip in general:

You can't fetch title and thumbnail for YouTube links that starts with youtu.be. This applies not only in Lemmy, but other websites too, for example Twitter (even before Elon's era).

This is, IMO due to the link doesn't really contain HTML and OpenGraph metadata. It only redirects you. If you try cURL-ing the youtu.be link, you will see that it doesn't have a response body, only some header including Location header that will tell you where to redirect. The response code itself is 301.

[–] Cris_Color@lemmy.world 2 points 3 days ago (1 children)

There are people on shitjustworks posting youtu.be links on !videos@lemmy.world that do have thumbnails, so whatever they're doing doesn't seem to have that problem

My .ee account has a field to put in a thumbnail URL, so other comments in this thread are kinda leading me to believe it may be a combination of instance version, and how the instance is configured

[–] hono4kami@slrpnk.net 3 points 3 days ago (1 children)

My Lemmy instance actually can't fetch YouTube thumbnail, so I actually have to put it manually lol.

See http://www.get-youtube-thumbnail.com/

[–] Cris_Color@lemmy.world 2 points 3 days ago

Thats a super helpful site, thank you! If nothing else now I can remake my post from my .ee account and add the thumbnail manually

[–] Cris_Color@lemmy.world 2 points 3 days ago (1 children)

Thats a very helpful response, thank you!

It seems like the only people getting thumbnails on !videos@lemmy.world are from shitjustworks (how fitting lol)

[–] hono4kami@slrpnk.net 4 points 3 days ago* (last edited 3 days ago) (1 children)

See the other reply: seems that it was caused by Lemmy backend only fetches the first 512kb of the HTML, meanwhile YouTube puts bunch of JavaScript in the beginning of the HTML

Here's the fix that was only merged couple days ago apparently, https://github.com/LemmyNet/lemmy/pull/5266

Crazy, right

[–] Cris_Color@lemmy.world 0 points 3 days ago

Interesting...

[–] sag@lemm.ee 2 points 3 days ago

Rate Limiting?

[–] Sergio@slrpnk.net 2 points 3 days ago* (last edited 3 days ago)

It looks like your "edit" is right (version of lemmy and instance configuration are an issue), with the additional complication that sometimes where it is hosted makes a difference (sometimes the youtube summary is in a different language and/or won't grab it because of regional restrictions) and sometimes the reader app/web interface grabs their own thumbnails and/or may not display thumbnails and/or may even try to just embed the video. There was a post on techsupport a while back about this: https://lemmy.world/post/20180043

I post to !fullmoviesonyoutube@lemm.ee from slrpnk.net and to get a thumbnail, I do the following:

  • get a thumbnail image file. either grab it from wikipedia, imdb, or by a screencap that I trim. put that file somewhere on my computer.
  • use the web interface with default client. It has a "thumbnail URL" field (which I didn't see back when I had a lemmy.world account - probably version differences) but I can't just upload the image to that field, so I have to...
  • go to the post "body" input field and click on the "upload image" button to upload the thumbnail image file from my computer. This uploads the image to the server and adds a line of code to the body input field that looks something like this: ![](https://slrpnk.net/pictrs/image/a-long-UUID.png)
  • copy the part from "https" to "png" and put it in the "thumbnail URL" field
  • usually I then delete that code from the post "body" input field
  • edit: of course, I still have to add the youtube URL in the "URL" field...

I think this adds thumbnails, but of course I can never be sure because someone can always use a client or configuration I'm unaware of. That's the price of freedom from a single corporate server and a limited choice of viewer clients.
Ideally this whole process would be easier or automatic. I imagine the situation/process will change as time gones on.

[–] muntedcrocodile@lemm.ee 1 points 3 days ago

U can configure ur instance to proxy thumbnails so u cant just scoop up ips from users directly. Youtube imposes strict rate limmits on ips hence if some wont load. I assume idk for certain tho.

[–] CaptDust@sh.itjust.works 1 points 3 days ago (1 children)

I have no clue what's different, but viewing the community using my instance shows thumbnails for nearly everything.

https://sh.itjust.works/c/videos@lemmy.world

[–] Cris_Color@lemmy.world 3 points 3 days ago* (last edited 3 days ago)

Most of them have it for me, but I just posted a video to the Souls-like comm and it doesn't have one, which is really what I'm trying to fix :/

[–] hanrahan@slrpnk.net 0 points 3 days ago* (last edited 3 days ago) (2 children)

From here on skrpnk.net using Boost, scolling down they all seem to have thumbnails?

[–] DarkThoughts@fedia.io 1 points 3 days ago

Mbin also shows thumbnails on all of them. https://fedia.io/m/videos@lemmy.world

[–] Cris_Color@lemmy.world 1 points 3 days ago

Interesting, I guess maybe boost separately fetches thumbnails for link posts that are missing them...