diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-10-23 21:04:15 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-10-23 21:04:15 -0500 |
| commit | be601a7584a1369938812d830bad8c4160dbcbd5 (patch) | |
| tree | 354a92eb154c9d052fe902499949a2b233f5602d | |
| parent | ceff2763a580f1af47227d75fadab1f7162efedb (diff) | |
| download | invidious-be601a7584a1369938812d830bad8c4160dbcbd5.tar.gz invidious-be601a7584a1369938812d830bad8c4160dbcbd5.tar.bz2 invidious-be601a7584a1369938812d830bad8c4160dbcbd5.zip | |
Fix handling for non-existent channels
| -rw-r--r-- | src/invidious/channels.cr | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 3a894b66..1d92dc87 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -190,11 +190,16 @@ def get_about_info(ucid) client = make_client(YT_URL) about = client.get("/channel/#{ucid}/about?disable_polymer=1&gl=US&hl=en") + if about.status_code == 404 + about = client.get("/user/#{ucid}/about?disable_polymer=1&gl=US&hl=en") + end + about = XML.parse_html(about.body) - if !about.xpath_node(%q(//span[contains(@class,"qualified-channel-title-text")]/a)) - about = client.get("/user/#{ucid}/about?disable_polymer=1&gl=US&hl=en") - about = XML.parse_html(about.body) + if about.xpath_node(%q(//div[contains(@class, "channel-empty-message")])) + error_message = "This channel does not exist." + + raise error_message end if about.xpath_node(%q(//span[contains(@class,"qualified-channel-title-text")]/a)).try &.content.empty? |
