Check deleted channels

This commit is contained in:
Omar Roth 2019-02-18 15:44:15 -06:00
parent f85472c0ce
commit 1ceb827a82

View File

@ -55,7 +55,7 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false)
active_channel = Channel(Bool).new active_channel = Channel(Bool).new
loop do loop do
db.query("SELECT id FROM channels WHERE deleted = false ORDER BY updated") do |rs| db.query("SELECT id FROM channels ORDER BY updated") do |rs|
rs.each do rs.each do
id = rs.read(String) id = rs.read(String)
@ -71,7 +71,7 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false)
client = make_client(YT_URL) client = make_client(YT_URL)
channel = fetch_channel(id, client, db, full_refresh) channel = fetch_channel(id, client, db, full_refresh)
db.exec("UPDATE channels SET updated = $1, author = $2 WHERE id = $3", Time.now, channel.author, id) db.exec("UPDATE channels SET updated = $1, author = $2, deleted = false WHERE id = $3", Time.now, channel.author, id)
rescue ex rescue ex
if ex.message == "Deleted or invalid channel" if ex.message == "Deleted or invalid channel"
db.exec("UPDATE channels SET deleted = true WHERE id = $1", id) db.exec("UPDATE channels SET deleted = true WHERE id = $1", id)