mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Add channel refresh
This commit is contained in:
parent
252f1c0af3
commit
edfe1eefe8
2 changed files with 24 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue