summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-04-28 09:27:05 -0500
committerOmar Roth <omarroth@hotmail.com>2018-04-28 09:32:36 -0500
commit6a7d19163eb7acb537c1b24dc8b1f5c1fab2be34 (patch)
treeb2aa1ee28c7b42942f9bc7103b4f09fee2090ae1
parentd753e52680372f78c287632e7d3b24c9e74be6f6 (diff)
downloadinvidious-6a7d19163eb7acb537c1b24dc8b1f5c1fab2be34.tar.gz
invidious-6a7d19163eb7acb537c1b24dc8b1f5c1fab2be34.tar.bz2
invidious-6a7d19163eb7acb537c1b24dc8b1f5c1fab2be34.zip
General cleanup
-rw-r--r--src/helpers.cr2
-rw-r--r--src/invidious.cr24
2 files changed, 13 insertions, 13 deletions
diff --git a/src/helpers.cr b/src/helpers.cr
index 1506a3dd..6cfe7baa 100644
--- a/src/helpers.cr
+++ b/src/helpers.cr
@@ -531,7 +531,7 @@ def login_req(login_form, f_req)
"flowEntry" => "ServiceLogin",
}
- data = data.merge(login_form)
+ data = login_form.merge(data)
return HTTP::Params.encode(data)
end
diff --git a/src/invidious.cr b/src/invidious.cr
index 2b8a8970..1948c8e2 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -20,8 +20,8 @@ require "option_parser"
require "pg"
require "xml"
require "yaml"
-require "./helpers"
require "./cookie_fix"
+require "./helpers"
CONFIG = Config.from_yaml(File.read("config/config.yml"))
@@ -147,10 +147,10 @@ spawn do
config.api_key = CONFIG.dl_api_key.not_nil!
end
filter = true
- else
- filter = false
end
+ filter ||= false
+
loop do
begin
top = rank_videos(PG_DB, 40, filter, YT_URL)
@@ -286,9 +286,8 @@ get "/watch" do |env|
if video.likes > 0 || video.dislikes > 0
calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
- else
- calculated_rating = 0.0
end
+ calculated_rating ||= 0.0
if video.info["ad_slots"]?
ad_slots = video.info["ad_slots"].split(",")
@@ -359,26 +358,23 @@ get "/search" do |env|
id = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/@href))
if id
id = id.content.lchop("/watch?v=")
- else
- id = ""
end
+ id ||= ""
video["id"] = id
title = root.xpath_node(%q(div[@class="yt-lockup-content"]/h3/a))
if title
video["title"] = title.content
- else
- video["title"] = ""
end
+ video["title"] ||= ""
author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))
if author
video["author"] = author.content
video["ucid_url"] = author["href"]
- else
- video["author"] = ""
- video["ucid_url"] = ""
end
+ video["author"] ||= ""
+ video["ucid_url"] ||= ""
videos << video
end
@@ -395,6 +391,10 @@ get "/login" do |env|
referer = "/feed/subscriptions"
end
+ if referer.size > 32
+ referer = "/feed/subscriptions"
+ end
+
templated "login"
end