diff options
author | 2024-03-30 03:05:50 -0500 | |
---|---|---|
committer | 2024-04-01 21:16:32 -0700 | |
commit | 1b8c45d162ea0aa19832f2d490badbf38eeede01 (patch) | |
tree | 48ff56ba18521e7cb8097ac49cdfdd9f26b958d4 /internal/reader/subscription/finder_test.go | |
parent | 19ce519836f6b2b924e7466deec2f7879fe77b2e (diff) | |
download | v2-1b8c45d162ea0aa19832f2d490badbf38eeede01.tar.gz v2-1b8c45d162ea0aa19832f2d490badbf38eeede01.tar.zst v2-1b8c45d162ea0aa19832f2d490badbf38eeede01.zip |
finder: Find feed from YouTube playlist
The feed from a YouTube playlist page is derived in practically the same way as a feed from a YouTube channel page.
Diffstat (limited to '')
-rw-r--r-- | internal/reader/subscription/finder_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/reader/subscription/finder_test.go b/internal/reader/subscription/finder_test.go index 160b52cb..216d81cb 100644 --- a/internal/reader/subscription/finder_test.go +++ b/internal/reader/subscription/finder_test.go @@ -8,6 +8,28 @@ import ( "testing" ) +func TestFindYoutubePlaylistFeed(t *testing.T) { + scenarios := map[string]string{ + "https://www.youtube.com/playlist?list=PLOOwEPgFWm_NHcQd9aCi5JXWASHO_n5uR": "https://www.youtube.com/feeds/videos.xml?playlist_id=PLOOwEPgFWm_NHcQd9aCi5JXWASHO_n5uR", + "https://www.youtube.com/playlist?list=PLOOwEPgFWm_N42HlCLhqyJ0ZBWr5K1QDM": "https://www.youtube.com/feeds/videos.xml?playlist_id=PLOOwEPgFWm_N42HlCLhqyJ0ZBWr5K1QDM", + } + + for websiteURL, expectedFeedURL := range scenarios { + subscriptions, localizedError := NewSubscriptionFinder(nil).FindSubscriptionsFromYouTubePlaylistPage(websiteURL) + if localizedError != nil { + t.Fatalf(`Parsing a correctly formatted YouTube playlist page should not return any error: %v`, localizedError) + } + + if len(subscriptions) != 1 { + t.Fatal(`Incorrect number of subscriptions returned`) + } + + if subscriptions[0].URL != expectedFeedURL { + t.Errorf(`Unexpected Feed, got %s, instead of %s`, subscriptions[0].URL, expectedFeedURL) + } + } +} + func TestFindYoutubeChannelFeed(t *testing.T) { scenarios := map[string]string{ "https://www.youtube.com/channel/UC-Qj80avWItNRjkZ41rzHyw": "https://www.youtube.com/feeds/videos.xml?channel_id=UC-Qj80avWItNRjkZ41rzHyw", |