|
|
@ -31,35 +31,6 @@ require "./invidious/*"
|
|
|
|
CONFIG = Config.from_yaml(File.read("config/config.yml"))
|
|
|
|
CONFIG = Config.from_yaml(File.read("config/config.yml"))
|
|
|
|
HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32)
|
|
|
|
HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32)
|
|
|
|
|
|
|
|
|
|
|
|
config = CONFIG
|
|
|
|
|
|
|
|
logger = Invidious::LogHandler.new
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kemal.config.extra_options do |parser|
|
|
|
|
|
|
|
|
parser.banner = "Usage: invidious [arguments]"
|
|
|
|
|
|
|
|
parser.on("-c THREADS", "--channel-threads=THREADS", "Number of threads for refreshing channels (default: #{config.channel_threads})") do |number|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
config.channel_threads = number.to_i
|
|
|
|
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
puts "THREADS must be integer"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on("-f THREADS", "--feed-threads=THREADS", "Number of threads for refreshing feeds (default: #{config.feed_threads})") do |number|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
config.feed_threads = number.to_i
|
|
|
|
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
puts "THREADS must be integer"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on("-o OUTPUT", "--output=OUTPUT", "Redirect output (default: STDOUT)") do |output|
|
|
|
|
|
|
|
|
FileUtils.mkdir_p(File.dirname(output))
|
|
|
|
|
|
|
|
logger = Invidious::LogHandler.new(File.open(output, mode: "a"))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kemal::CLI.new ARGV
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PG_URL = URI.new(
|
|
|
|
PG_URL = URI.new(
|
|
|
|
scheme: "postgres",
|
|
|
|
scheme: "postgres",
|
|
|
|
user: CONFIG.db[:user],
|
|
|
|
user: CONFIG.db[:user],
|
|
|
@ -81,6 +52,12 @@ CURRENT_BRANCH = {{ "#{`git branch | sed -n '/\* /s///p'`.strip}" }}
|
|
|
|
CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }}
|
|
|
|
CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }}
|
|
|
|
CURRENT_VERSION = {{ "#{`git describe --tags --abbrev=0`.strip}" }}
|
|
|
|
CURRENT_VERSION = {{ "#{`git describe --tags --abbrev=0`.strip}" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SOFTWARE = {
|
|
|
|
|
|
|
|
"name" => "invidious",
|
|
|
|
|
|
|
|
"version" => "#{CURRENT_VERSION}-#{CURRENT_COMMIT}",
|
|
|
|
|
|
|
|
"branch" => "#{CURRENT_BRANCH}",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOCALES = {
|
|
|
|
LOCALES = {
|
|
|
|
"ar" => load_locale("ar"),
|
|
|
|
"ar" => load_locale("ar"),
|
|
|
|
"de" => load_locale("de"),
|
|
|
|
"de" => load_locale("de"),
|
|
|
@ -95,6 +72,39 @@ LOCALES = {
|
|
|
|
"ru" => load_locale("ru"),
|
|
|
|
"ru" => load_locale("ru"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = CONFIG
|
|
|
|
|
|
|
|
logger = Invidious::LogHandler.new
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kemal.config.extra_options do |parser|
|
|
|
|
|
|
|
|
parser.banner = "Usage: invidious [arguments]"
|
|
|
|
|
|
|
|
parser.on("-c THREADS", "--channel-threads=THREADS", "Number of threads for refreshing channels (default: #{config.channel_threads})") do |number|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
config.channel_threads = number.to_i
|
|
|
|
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
puts "THREADS must be integer"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on("-f THREADS", "--feed-threads=THREADS", "Number of threads for refreshing feeds (default: #{config.feed_threads})") do |number|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
config.feed_threads = number.to_i
|
|
|
|
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
puts "THREADS must be integer"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on("-o OUTPUT", "--output=OUTPUT", "Redirect output (default: STDOUT)") do |output|
|
|
|
|
|
|
|
|
FileUtils.mkdir_p(File.dirname(output))
|
|
|
|
|
|
|
|
logger = Invidious::LogHandler.new(File.open(output, mode: "a"))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on("-v", "--version", "Print version") do |output|
|
|
|
|
|
|
|
|
puts SOFTWARE.to_pretty_json
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kemal::CLI.new ARGV
|
|
|
|
|
|
|
|
|
|
|
|
refresh_channels(PG_DB, logger, config.channel_threads, config.full_refresh)
|
|
|
|
refresh_channels(PG_DB, logger, config.channel_threads, config.full_refresh)
|
|
|
|
|
|
|
|
|
|
|
|
refresh_feeds(PG_DB, logger, config.feed_threads)
|
|
|
|
refresh_feeds(PG_DB, logger, config.feed_threads)
|
|
|
@ -108,12 +118,8 @@ if config.statistics_enabled
|
|
|
|
spawn do
|
|
|
|
spawn do
|
|
|
|
loop do
|
|
|
|
loop do
|
|
|
|
statistics = {
|
|
|
|
statistics = {
|
|
|
|
"version" => "2.0",
|
|
|
|
"version" => "2.0",
|
|
|
|
"software" => {
|
|
|
|
"software" => SOFTWARE,
|
|
|
|
"name" => "invidious",
|
|
|
|
|
|
|
|
"version" => "#{CURRENT_VERSION}-#{CURRENT_COMMIT}",
|
|
|
|
|
|
|
|
"branch" => "#{CURRENT_BRANCH}",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"openRegistrations" => config.registration_enabled,
|
|
|
|
"openRegistrations" => config.registration_enabled,
|
|
|
|
"usage" => {
|
|
|
|
"usage" => {
|
|
|
|
"users" => {
|
|
|
|
"users" => {
|
|
|
|