summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-07-29 21:01:28 -0500
committerOmar Roth <omarroth@hotmail.com>2018-07-29 21:01:28 -0500
commita09b12a77498771bc0bd326270ad01f5cc78aec4 (patch)
tree3e7fd6f67cba3bef85ceaf7d0e8fd499d0dfb370 /src
parent503c47c8bf9da16bfb82b301610ff7dd88c65faf (diff)
downloadinvidious-a09b12a77498771bc0bd326270ad01f5cc78aec4.tar.gz
invidious-a09b12a77498771bc0bd326270ad01f5cc78aec4.tar.bz2
invidious-a09b12a77498771bc0bd326270ad01f5cc78aec4.zip
Add fix for nonexistent channels
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 11c502e5..a61bb375 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -1146,9 +1146,15 @@ get "/api/v1/channels/:ucid/videos" do |env|
response = client.get(url)
json = JSON.parse(response.body)
+ if !json["content_html"]?
+ env.response.content_type = "application/json"
+ next {"error" => "No videos or nonexistent channel"}.to_json
+ end
+
content_html = json["content_html"].as_s
if content_html.empty?
- halt env, status_code: 403
+ env.response.content_type = "application/json"
+ next Hash(String, String).new.to_json
end
document = XML.parse_html(content_html)
@@ -1843,6 +1849,11 @@ get "/feed/channel/:ucid" do |env|
channel = get_channel(ucid, client, PG_DB, pull_all_videos: false)
json = JSON.parse(response.body)
+ if !json["content_html"]?
+ error_message = "This channel does not exist or has no videos."
+ next templated "error"
+ end
+
content_html = json["content_html"].as_s
if content_html.empty?
halt env, status_code: 403
@@ -2222,6 +2233,11 @@ get "/channel/:ucid" do |env|
response = client.get(url)
json = JSON.parse(response.body)
+ if !json["content_html"]?
+ error_message = "This channel does not exist or has no videos."
+ next templated "error"
+ end
+
if json["content_html"].as_s.strip(" \n").empty?
rss = client.get("/feeds/videos.xml?channel_id=#{ucid}").body
rss = XML.parse_html(rss)