mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-25 23:17:23 +00:00
Add 'deleted' to channel info
This commit is contained in:
parent
7a9ef0d664
commit
30e6d29106
4
config/migrate-scripts/migrate-db-e1aa1ce.sh
Normal file
4
config/migrate-scripts/migrate-db-e1aa1ce.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
psql invidious -c "ALTER TABLE channels ADD COLUMN deleted bool;"
|
||||||
|
psql invidious -c "UPDATE channels SET deleted = false;"
|
@ -7,6 +7,7 @@ CREATE TABLE public.channels
|
|||||||
id text NOT NULL,
|
id text NOT NULL,
|
||||||
author text,
|
author text,
|
||||||
updated timestamp with time zone,
|
updated timestamp with time zone,
|
||||||
|
deleted boolean,
|
||||||
CONSTRAINT channels_id_key UNIQUE (id)
|
CONSTRAINT channels_id_key UNIQUE (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ class InvidiousChannel
|
|||||||
id: String,
|
id: String,
|
||||||
author: String,
|
author: String,
|
||||||
updated: Time,
|
updated: Time,
|
||||||
|
deleted: Bool,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -187,7 +188,7 @@ def fetch_channel(ucid, client, db, pull_all_videos = true, locale = nil)
|
|||||||
db.exec("DELETE FROM channel_videos * WHERE NOT id = ANY ('{#{ids.map { |id| %("#{id}") }.join(",")}}') AND ucid = $1", ucid)
|
db.exec("DELETE FROM channel_videos * WHERE NOT id = ANY ('{#{ids.map { |id| %("#{id}") }.join(",")}}') AND ucid = $1", ucid)
|
||||||
end
|
end
|
||||||
|
|
||||||
channel = InvidiousChannel.new(ucid, author, Time.now)
|
channel = InvidiousChannel.new(ucid, author, Time.now, false)
|
||||||
|
|
||||||
return channel
|
return channel
|
||||||
end
|
end
|
||||||
|
@ -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 ORDER BY updated") do |rs|
|
db.query("SELECT id FROM channels WHERE deleted = false ORDER BY updated") do |rs|
|
||||||
rs.each do
|
rs.each do
|
||||||
id = rs.read(String)
|
id = rs.read(String)
|
||||||
|
|
||||||
@ -73,6 +73,9 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false)
|
|||||||
|
|
||||||
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 WHERE id = $3", Time.now, channel.author, id)
|
||||||
rescue ex
|
rescue ex
|
||||||
|
if ex.message == "Deleted or invalid channel"
|
||||||
|
db.exec("UPDATE channels SET deleted = true WHERE id = $1", id)
|
||||||
|
end
|
||||||
logger.write("#{id} : #{ex.message}\n")
|
logger.write("#{id} : #{ex.message}\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user