Getting those thumbnails from Medium RSS Feed
TL;DR They are in the description now
A few months ago, I hosted my website, and to fill the void, I decided to throw in my Medium Articles there. While I was paying Mickey in Florida, Medium decided to get serious about data crawling and made some changes not only to its web app but also to the RSS Feed.
Those sweet little thumbnails were now empty 🥺
Refresher on RSS Feed
RSS (Really Simple Syndication) is a type of web feed that provides users with a convenient way to access updates from multiple sources in a uniform format. This format is standardized and allows publishers to distribute various types of content, such as blog entries, news headlines, podcasts, and more. The information in the RSS feed is standardized, making it easy for third-party services to aggregate them and for software programs to parse and display the content. Moreover, the publisher can customize RSS feeds with additional metadata, are search engine friendly, and include rich media such as images, videos, and audio files.
Overall, RSS feeds provide a convenient and efficient way to distribute and access content from multiple sources in a
standardized format.
To access someone’s Medium RSS feed, you could go the RSS Feed URL similar to https://medium.com/feed/@kartikyathakur
This will return the RSS Feed in XML format.
However, if you want to parse it quickly, then consider something like rssToJson, and pass the above URL to it and you’ll get a JSON version of the same information:
https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@kartikyathakur
The issue
The thumbnail images are missing because we are no longer getting the thumbnail URL in the JSON field we expect it to be, where it used to be.
The Fix
The moment I realized this, I wanted to fix it. Quick fix: download the thumbnails and then serve them myself. But that would mean I’d have to map it manually against each thumbnail, which would bind me to perform this exercise whenever I wrote a new article.
While taking another look at the RSS feed, I realized that the image URLs were still there in the description. They are not that easy to access, but they are still there.
A tiny bit of regex is all that was needed to extract those out.
In my NodeJS project, the following changes were needed just replacing:
article['thumbnail']
With:
(article['description'] as any).toString().match(/<img[^>]+src="([^">]+)"/)[1]
Making that quick change brought my thumbnails back for now… unless Medium also decides to take those URLs out of the description.
P.S. Medium, please disregard this article 👨🏽💻