summaryrefslogtreecommitdiffstats
path: root/src/invidious.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/invidious.cr')
-rw-r--r--src/invidious.cr33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 18aa049a..f91e4c72 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -131,6 +131,19 @@ before_all do |env|
end
end
end
+
+ current_page = env.request.path
+ if env.request.query
+ query = HTTP::Params.parse(env.request.query.not_nil!)
+
+ if query["referer"]?
+ query["referer"] = get_referer(env, "/")
+ end
+
+ current_page += "?#{query}"
+ end
+
+ env.set "current_page", URI.escape(current_page)
end
get "/" do |env|
@@ -436,8 +449,7 @@ end
# See https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L79
post "/login" do |env|
- referer = env.params.query["referer"]?
- referer ||= get_referer(env, "/feed/subscriptions")
+ referer = get_referer(env, "/feed/subscriptions")
email = env.params.body["email"]?
password = env.params.body["password"]?
@@ -531,7 +543,7 @@ post "/login" do |env|
end
if !tfa_code
- next env.redirect "/login?tfa=true&type=google"
+ next env.redirect "/login?tfa=true&type=google&referer=#{URI.escape(referer)}"
end
tl = challenge_results[1][2]
@@ -702,7 +714,7 @@ get "/signout" do |env|
end
env.request.cookies.add_response_headers(env.response.headers)
- env.redirect referer
+ env.redirect URI.unescape(referer)
end
get "/preferences" do |env|
@@ -1692,7 +1704,7 @@ get "/api/v1/comments/:id" do |env|
if format == "json"
next {"comments" => [] of String}.to_json
else
- next {"content_html" => ""}.to_json
+ next {"contentHtml" => ""}.to_json
end
end
ctoken = ctoken["ctoken"]
@@ -1730,7 +1742,7 @@ get "/api/v1/comments/:id" do |env|
if format == "json"
next {"comments" => [] of String}.to_json
else
- next {"content_html" => ""}.to_json
+ next {"contentHtml" => ""}.to_json
end
end
@@ -1830,7 +1842,8 @@ get "/api/v1/comments/:id" do |env|
comments = JSON.parse(comments)
content_html = template_youtube_comments(comments)
- next {"content_html" => content_html}.to_json
+ next {"contentHtml" => content_html,
+ "commentCount" => comments["commentCount"]}.to_json
end
elsif source == "reddit"
client = make_client(REDDIT_URL)
@@ -1851,9 +1864,9 @@ get "/api/v1/comments/:id" do |env|
end
env.response.content_type = "application/json"
- next {"title" => reddit_thread.title,
- "permalink" => reddit_thread.permalink,
- "content_html" => content_html}.to_json
+ next {"title" => reddit_thread.title,
+ "permalink" => reddit_thread.permalink,
+ "contentHtml" => content_html}.to_json
end
end