summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-04-01 10:09:08 -0500
committerOmar Roth <omarroth@hotmail.com>2018-04-01 10:09:08 -0500
commita54f59ad742af9c8d86a7fe947a48857813609d7 (patch)
tree8008daa1f51bc48570d2f47703e88bd04485d439 /src
parent29545a7a6ffebf7905cb17a1518a84bda3cff3d0 (diff)
downloadinvidious-a54f59ad742af9c8d86a7fe947a48857813609d7.tar.gz
invidious-a54f59ad742af9c8d86a7fe947a48857813609d7.tar.bz2
invidious-a54f59ad742af9c8d86a7fe947a48857813609d7.zip
Minor refactor
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 5569fc02..2f7c3c89 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -206,8 +206,7 @@ get "/watch" do |env|
if env.params.query["v"]?
id = env.params.query["v"]
else
- env.redirect "/"
- next
+ next env.redirect "/"
end
listen = false
@@ -317,8 +316,7 @@ get "/search" do |env|
if env.params.query["q"]?
query = env.params.query["q"]
else
- env.redirect "/"
- next
+ next env.redirect "/"
end
page = env.params.query["page"]?.try &.to_i
@@ -350,7 +348,7 @@ get "/search" do |env|
if title
video["title"] = title.content
else
- video["title"] = "Something went wrong"
+ video["title"] = ""
end
author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))
@@ -701,8 +699,7 @@ get "/subscription_ajax" do |env|
elsif env.params.query["action_remove_subscriptions"]?
action = "action_remove_subscriptions"
else
- action = ""
- env.redirect referer
+ next env.redirect referer
end
channel_id = env.params.query["c"]?
@@ -713,7 +710,9 @@ get "/subscription_ajax" do |env|
client = get_client(youtube_pool)
subs = client.get("/subscription_manager?disable_polymer=1", headers)
+
headers["Cookie"] += "; " + subs.cookies.add_request_headers(headers)["Cookie"]
+
match = subs.body.match(/'XSRF_TOKEN': "(?<session_token>[A-Za-z0-9\_\-\=]+)"/)
if match
session_token = match["session_token"]