mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-06 12:48:29 +00:00
Move decrypt function updating into job class
This commit is contained in:
parent
cfef390c9d
commit
ddc8892624
@ -168,19 +168,14 @@ if config.statistics_enabled
|
||||
end
|
||||
|
||||
Invidious::Jobs.register Invidious::Jobs::PullPopularVideosJob.new(PG_DB)
|
||||
Invidious::Jobs.register Invidious::Jobs::UpdateDecryptFunctionJob.new
|
||||
Invidious::Jobs.start_all
|
||||
|
||||
def popular_videos
|
||||
Invidious::Jobs::PullPopularVideosJob::POPULAR_VIDEOS.get
|
||||
end
|
||||
|
||||
DECRYPT_FUNCTION = [] of {SigProc, Int32}
|
||||
spawn do
|
||||
update_decrypt_function do |function|
|
||||
DECRYPT_FUNCTION.clear
|
||||
function.each { |i| DECRYPT_FUNCTION << i }
|
||||
end
|
||||
end
|
||||
DECRYPT_FUNCTION = Invidious::Jobs::UpdateDecryptFunctionJob::DECRYPT_FUNCTION
|
||||
|
||||
if CONFIG.captcha_key
|
||||
spawn do
|
||||
|
@ -65,21 +65,6 @@ def pull_popular_videos(db)
|
||||
end
|
||||
end
|
||||
|
||||
def update_decrypt_function
|
||||
loop do
|
||||
begin
|
||||
decrypt_function = fetch_decrypt_function
|
||||
yield decrypt_function
|
||||
rescue ex
|
||||
# TODO: Log error
|
||||
next
|
||||
ensure
|
||||
sleep 1.minute
|
||||
Fiber.yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def bypass_captcha(captcha_key, logger)
|
||||
loop do
|
||||
begin
|
||||
|
19
src/invidious/jobs/update_decrypt_function_job.cr
Normal file
19
src/invidious/jobs/update_decrypt_function_job.cr
Normal file
@ -0,0 +1,19 @@
|
||||
class Invidious::Jobs::UpdateDecryptFunctionJob < Invidious::Jobs::BaseJob
|
||||
DECRYPT_FUNCTION = [] of {SigProc, Int32}
|
||||
|
||||
def begin
|
||||
loop do
|
||||
begin
|
||||
decrypt_function = fetch_decrypt_function
|
||||
DECRYPT_FUNCTION.clear
|
||||
decrypt_function.each { |df| DECRYPT_FUNCTION << df }
|
||||
rescue ex
|
||||
# TODO: Log error
|
||||
next
|
||||
ensure
|
||||
sleep 1.minute
|
||||
Fiber.yield
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user