From 133b72f9cff17463a5519213b03049832348bc97 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 9 Sep 2018 08:53:04 -0500 Subject: [PATCH] Add support for genre channels that don't end with " - Topic" --- src/invidious.cr | 12 ++++++++---- src/invidious/users.cr | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 5f649d73..78cbd454 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1403,7 +1403,8 @@ get "/feed/channel/:ucid" do |env| # Auto-generated channels # https://support.google.com/youtube/answer/2579942 - if author.ends_with? " - Topic" + if author.ends_with?(" - Topic") || + {"Popular on YouTube", "Music", "Sports", "Gaming"}.includes? author auto_generated = true end @@ -1660,7 +1661,8 @@ get "/channel/:ucid" do |env| # Auto-generated channels # https://support.google.com/youtube/answer/2579942 - if author.ends_with? " - Topic" + if author.ends_with?(" - Topic") || + {"Popular on YouTube", "Music", "Sports", "Gaming"}.includes? author auto_generated = true end @@ -2330,7 +2332,8 @@ get "/api/v1/channels/:ucid" do |env| # Auto-generated channels # https://support.google.com/youtube/answer/2579942 - if author.ends_with? " - Topic" + if author.ends_with?(" - Topic") || + {"Popular on YouTube", "Music", "Sports", "Gaming"}.includes? author auto_generated = true end @@ -2512,7 +2515,8 @@ get "/api/v1/channels/:ucid/videos" do |env| # Auto-generated channels # https://support.google.com/youtube/answer/2579942 - if author.ends_with? " - Topic" + if author.ends_with?(" - Topic") || + {"Popular on YouTube", "Music", "Sports", "Gaming"}.includes? author auto_generated = true end diff --git a/src/invidious/users.cr b/src/invidious/users.cr index fa3a5f6e..3ce9d9af 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -140,7 +140,7 @@ def fetch_user(sid, client, headers, db) channels = [] of String feed.xpath_nodes(%q(//ul[@id="guide-channels"]/li/a)).each do |channel| - if !["Popular on YouTube", "Music", "Sports", "Gaming"].includes? channel["title"] + if !{"Popular on YouTube", "Music", "Sports", "Gaming"}.includes? channel["title"] channel_id = channel["href"].lstrip("/channel/") begin