summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-08-08 10:20:07 -0500
committerOmar Roth <omarroth@hotmail.com>2018-08-08 10:20:07 -0500
commit3ebe9139b7b418b8667cee3cb67b33be80655167 (patch)
tree35773dbcefabdd9f8cc464583f1501cbe8dd723d
parentf3c7409d7216d18ca510dca9fce3af927df0f1b1 (diff)
downloadinvidious-3ebe9139b7b418b8667cee3cb67b33be80655167.tar.gz
invidious-3ebe9139b7b418b8667cee3cb67b33be80655167.tar.bz2
invidious-3ebe9139b7b418b8667cee3cb67b33be80655167.zip
Provide response on video error
-rw-r--r--src/invidious.cr14
-rw-r--r--src/invidious/helpers/utils.cr2
2 files changed, 9 insertions, 7 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index ffac2717..c7081d94 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -1752,7 +1752,7 @@ get "/api/v1/comments/:id" do |env|
env.response.content_type = "application/json"
if !response["response"]["continuationContents"]?
- halt env, status_code: 401
+ halt env, status_code: 403
end
response = response["response"]["continuationContents"]
@@ -1862,7 +1862,7 @@ get "/api/v1/comments/:id" do |env|
comments = JSON.parse(comments)
content_html = template_youtube_comments(comments)
- {"content_html" => content_html}.to_json
+ next {"content_html" => content_html}.to_json
end
elsif source == "reddit"
client = make_client(REDDIT_URL)
@@ -1883,9 +1883,9 @@ get "/api/v1/comments/:id" do |env|
end
env.response.content_type = "application/json"
- {"title" => reddit_thread.title,
- "permalink" => reddit_thread.permalink,
- "content_html" => content_html}.to_json
+ next {"title" => reddit_thread.title,
+ "permalink" => reddit_thread.permalink,
+ "content_html" => content_html}.to_json
end
end
@@ -1895,7 +1895,9 @@ get "/api/v1/videos/:id" do |env|
begin
video = get_video(id, PG_DB)
rescue ex
- halt env, status_code: 403
+ env.response.content_type = "application/json"
+ response = {"error" => ex.message}.to_json
+ halt env, status_code: 500, response: response
end
fmt_stream = video.fmt_stream(decrypt_function)
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index db49bab0..04de0f9b 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -68,7 +68,7 @@ def decode_date(string : String)
return Time.new(string.to_i, 1, 1)
end
- # String matches format "20 hours ago", "40 minutes ago"...
+ # String matches format "20 hours ago", "4 months ago"...
date = string.split(" ")[-3, 3]
delta = date[0].to_i