mirror of https://github.com/iv-org/invidious.git
General cleanup
This commit is contained in:
parent
d753e52680
commit
6a7d19163e
|
@ -531,7 +531,7 @@ def login_req(login_form, f_req)
|
||||||
"flowEntry" => "ServiceLogin",
|
"flowEntry" => "ServiceLogin",
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data.merge(login_form)
|
data = login_form.merge(data)
|
||||||
|
|
||||||
return HTTP::Params.encode(data)
|
return HTTP::Params.encode(data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,8 +20,8 @@ require "option_parser"
|
||||||
require "pg"
|
require "pg"
|
||||||
require "xml"
|
require "xml"
|
||||||
require "yaml"
|
require "yaml"
|
||||||
require "./helpers"
|
|
||||||
require "./cookie_fix"
|
require "./cookie_fix"
|
||||||
|
require "./helpers"
|
||||||
|
|
||||||
CONFIG = Config.from_yaml(File.read("config/config.yml"))
|
CONFIG = Config.from_yaml(File.read("config/config.yml"))
|
||||||
|
|
||||||
|
@ -147,10 +147,10 @@ spawn do
|
||||||
config.api_key = CONFIG.dl_api_key.not_nil!
|
config.api_key = CONFIG.dl_api_key.not_nil!
|
||||||
end
|
end
|
||||||
filter = true
|
filter = true
|
||||||
else
|
|
||||||
filter = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
filter ||= false
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
begin
|
begin
|
||||||
top = rank_videos(PG_DB, 40, filter, YT_URL)
|
top = rank_videos(PG_DB, 40, filter, YT_URL)
|
||||||
|
@ -286,9 +286,8 @@ get "/watch" do |env|
|
||||||
|
|
||||||
if video.likes > 0 || video.dislikes > 0
|
if video.likes > 0 || video.dislikes > 0
|
||||||
calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
|
calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
|
||||||
else
|
|
||||||
calculated_rating = 0.0
|
|
||||||
end
|
end
|
||||||
|
calculated_rating ||= 0.0
|
||||||
|
|
||||||
if video.info["ad_slots"]?
|
if video.info["ad_slots"]?
|
||||||
ad_slots = video.info["ad_slots"].split(",")
|
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))
|
id = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/@href))
|
||||||
if id
|
if id
|
||||||
id = id.content.lchop("/watch?v=")
|
id = id.content.lchop("/watch?v=")
|
||||||
else
|
|
||||||
id = ""
|
|
||||||
end
|
end
|
||||||
|
id ||= ""
|
||||||
video["id"] = id
|
video["id"] = id
|
||||||
|
|
||||||
title = root.xpath_node(%q(div[@class="yt-lockup-content"]/h3/a))
|
title = root.xpath_node(%q(div[@class="yt-lockup-content"]/h3/a))
|
||||||
if title
|
if title
|
||||||
video["title"] = title.content
|
video["title"] = title.content
|
||||||
else
|
|
||||||
video["title"] = ""
|
|
||||||
end
|
end
|
||||||
|
video["title"] ||= ""
|
||||||
|
|
||||||
author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))
|
author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))
|
||||||
if author
|
if author
|
||||||
video["author"] = author.content
|
video["author"] = author.content
|
||||||
video["ucid_url"] = author["href"]
|
video["ucid_url"] = author["href"]
|
||||||
else
|
|
||||||
video["author"] = ""
|
|
||||||
video["ucid_url"] = ""
|
|
||||||
end
|
end
|
||||||
|
video["author"] ||= ""
|
||||||
|
video["ucid_url"] ||= ""
|
||||||
|
|
||||||
videos << video
|
videos << video
|
||||||
end
|
end
|
||||||
|
@ -395,6 +391,10 @@ get "/login" do |env|
|
||||||
referer = "/feed/subscriptions"
|
referer = "/feed/subscriptions"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if referer.size > 32
|
||||||
|
referer = "/feed/subscriptions"
|
||||||
|
end
|
||||||
|
|
||||||
templated "login"
|
templated "login"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue