Invidious is an alternative front-end to YouTube
Add back in refreshing of channels every 2 days
matthewmcgarveye92b3779ad6a
diff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.crindex b9f762e7..6905b6f8 100644--- a/src/invidious/channels/channels.cr+++ b/src/invidious/channels/channels.cr@@ -152,12 +152,14 @@ def get_batch_channels(channels)return finalend-def get_channel(id)+def get_channel(id) : InvidiousChannelchannel = Invidious::Database::Channels.select(id)- return channel if channel- channel = fetch_channel(id, pull_all_videos: false)- Invidious::Database::Channels.insert(channel)+ if channel.nil? || (Time.utc - channel.updated) > 2.days+ channel = fetch_channel(id, pull_all_videos: false)+ Invidious::Database::Channels.insert(channel, update_on_conflict: true)+ end+return channelenddiff --git a/src/invidious/database/channels.cr b/src/invidious/database/channels.crindex e88b4989..134cf59d 100644--- a/src/invidious/database/channels.cr+++ b/src/invidious/database/channels.cr@@ -10,7 +10,7 @@ module Invidious::Database::Channels# Insert / delete# -------------------- def insert(channel : InvidiousChannel)+ def insert(channel : InvidiousChannel, update_on_conflict : Bool = false)channel_array = channel.to_arequest = <<-SQL@@ -18,6 +18,13 @@ module Invidious::Database::ChannelsVALUES (#{arg_array(channel_array)})SQL+ if update_on_conflict+ request += <<-SQL+ ON CONFLICT (id) DO UPDATE+ SET author = $2, updated = $3+ SQL+ end+PG_DB.exec(request, args: channel_array)end