mirror of
https://github.com/iv-org/invidious.git
synced 2025-11-05 23:22:01 +00:00
Add channel refresh
This commit is contained in:
@@ -27,6 +27,7 @@ CONFIG = Config.from_yaml(File.read("config/config.yml"))
|
||||
|
||||
pool_size = CONFIG.pool_size
|
||||
threads = CONFIG.threads
|
||||
channel_threads = 10
|
||||
|
||||
Kemal.config.extra_options do |parser|
|
||||
parser.banner = "Usage: invidious [arguments]"
|
||||
@@ -122,6 +123,24 @@ threads.times do
|
||||
end
|
||||
end
|
||||
|
||||
channel_threads.times do |i|
|
||||
spawn do
|
||||
loop do
|
||||
query = "SELECT id FROM channels ORDER BY updated \
|
||||
LIMIT (SELECT count(*)/#{channel_threads} FROM channels) \
|
||||
OFFSET (SELECT count(*)*#{i}/#{channel_threads} FROM channels)"
|
||||
PG_DB.query(query) do |rs|
|
||||
rs.each do
|
||||
client = get_client(youtube_pool)
|
||||
id = rs.read(String)
|
||||
channel = get_channel(id, client, PG_DB)
|
||||
youtube_pool << client
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
top_videos = [] of Video
|
||||
|
||||
spawn do
|
||||
|
||||
Reference in New Issue
Block a user