Repository navigation
[xExtension-YouTube] Convert playlist URLs to their feed URL - #595
Merged
Merged
Conversation
YouTube channel pages advertise their feed with a <link rel="alternate">, so FreshRSS discovers it when a channel or @handle URL is pasted, but playlist pages do not. Subscribing to a playlist page, e.g. with the subscription bookmarklet, therefore failed with "A feed could not be found" (FreshRSS/FreshRSS#6389), and users had to build the feed URL themselves. The check_url_before_add hook of the extension now also converts playlist URLs, from www.youtube.com, youtube.com (share links) and m.youtube.com, to https://www.youtube.com/feeds/videos.xml?playlist_id=… The `list` parameter may be anywhere in the query, and other parameters (such as `si` from share links) and fragments are ignored. FreshRSS passes the URL HTML-encoded to the hook (`&` between the query parameters), so the URL is decoded before being matched. The playlist ID is restricted to the characters used by YouTube; any other URL is returned unchanged. Add tests/YouTubeTest.php, a dependency-free regression test of the URL conversion on the model of tests/ImageProxyTest.php, run by the new `test-youtube` Composer script, `composer test` and the CI workflow. Document playlist URLs in the README, add a changelog entry and bump the version to 1.5.0.
Alkarex
approved these changes
Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
YouTube channel pages advertise their feed (
<link rel="alternate" type="application/rss+xml">), so FreshRSS finds it when a channel or@handleURL is pasted, but playlist pages do not. Subscribing tohttps://www.youtube.com/playlist?list=…, e.g. with the bookmarklet, fails with A feed could not be found (FreshRSS/FreshRSS#6389, where it was suggested that this gap is better solved by an extension), so users have to build the feed URL themselves.check_url_before_addhook of the extension, which already converts/channel/and/user/URLs, now converts playlist URLs tohttps://www.youtube.com/feeds/videos.xml?playlist_id=…www.youtube.com,youtube.com(e.g. share links) andm.youtube.com. The channel and user conversions are left as they are: on those hosts, these pages redirect towww.youtube.comand advertise their feed anywaylistparameter may be anywhere in the query string; other parameters (e.g.siof share links) and fragments are ignored&between the query parameters, from the web interface as well as from the Google Reader API), so the URL is decoded before being matched[0-9a-zA-Z_-]; any other URL, including video URLs with alistparameter, is returned unchangedtests/YouTubeTest.php, a dependency-free regression test of the URL conversion on the model oftests/ImageProxyTest.php, run by a newtest-youtubeComposer script (also part ofcomposer test) and by the CI workflowPlaylist feeds have no link to a website, so the automatic channel icons do not apply to them, as for the playlist feeds that are added manually today.
Note: #581 also bumps the YouTube extension to 1.5.0, so whichever is merged second will need a small rebase of
metadata.jsonand of the changelog, which I will take care of.Validation
edge(PHP 8.4, SQLite) and the extension enabled:?c=feed&a=add&url_rss=…, as opened by the bookmarklet) ofhttps://youtube.com/playlist?app=desktop&list=PLbpi6ZahtOH6Blw3RGYpWkSByi_T7Rygbshows the playlist Top Trending Videos of the Week, withhttps://www.youtube.com/feeds/videos.xml?playlist_id=PLbpi6ZahtOH6Blw3RGYpWkSByi_T7Rygbas feed URLhttps://m.youtube.com/playlist?si=a1B2c3&list=PLbpi6ZahtOH6Blw3RGYpWkSByi_T7Rygbadds that feed; after a refresh, its 15 entries are displayed with the embedded player, without any PHP warningmain), the subscription fails with A feed could not be found athttps://youtube.com/playlist?…; the status code is200and content-type istext/html; charset=utf-8tests/YouTubeTest.php(21 assertions) passes, and fails without the change ofextension.phpphp-lint,phtml-lint,test-image-proxy,phpcs,phpstan(with../FreshRSS),markdownlint,eslint,stylelintandtypos