Morsel #13: YouTube max thumbnail grabber


A while back, I made a YouTube thumbnail grabber for my Terminal using Python. Here’s a command example:

py yt.py -u "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

But I’m lazy and wanted something I could just access online. Boing Boing already has a thumbnail grabber but it displays all thumbnail sizes. I just need the biggest (as I used them for featured images on my blogs) so rather than copy, I decided to use Google’s Gemini to generate the code.

Please note: I have looked through the code, tested it, and rewritten some of it as not to just copy and paste AI-generated content. However, if you see any non-stylistic issues with the code, please let me know.

How the code works

I have a standard form with a text input and a submit button. When I enter a valid YouTube URL and click submit, the script checks for validity (and ensures no attempts at XSS attacks get through), extracts the video ID and creates the thumbnail URL to display.

If an invalid YouTube URL is submitted, you get an error message (try it and see!). You also can’t submit an empty field either as it will warn you.

The reason I used AI for this is because I was trying to recreate code that I’d written elsewhere and it wasn’t working and I could foresee losing hours and hours of my life when I could just get a large language model to do it and check the work.

Morsel #12: styling a WordPress post to look like a Bluesky post Morsel #14: Textlist to array