mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Fix conflict on video update
This commit is contained in:
parent
6c934542a6
commit
6660b2b56b
1 changed files with 8 additions and 5 deletions
|
@ -257,7 +257,7 @@ def get_video(id, client, db, refresh = true)
|
||||||
video_array = video.to_a
|
video_array = video.to_a
|
||||||
args = arg_array(video_array[1..-1], 2)
|
args = arg_array(video_array[1..-1], 2)
|
||||||
|
|
||||||
db.exec("UPDATE videos SET (info,updated,title,views,likes,dislikes,wilson_score,published,description,language)\
|
db.exec("UPDATE videos SET (info,updated,title,views,likes,dislikes,wilson_score,published,description,language,author,ucid)\
|
||||||
= (#{args}) WHERE id = $1", video_array)
|
= (#{args}) WHERE id = $1", video_array)
|
||||||
rescue ex
|
rescue ex
|
||||||
db.exec("DELETE FROM videos * WHERE id = $1", id)
|
db.exec("DELETE FROM videos * WHERE id = $1", id)
|
||||||
|
@ -265,8 +265,10 @@ def get_video(id, client, db, refresh = true)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
video = fetch_video(id, client)
|
video = fetch_video(id, client)
|
||||||
args = arg_array(video.to_a)
|
video_array = video.to_a
|
||||||
db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video.to_a)
|
args = arg_array(video_array)
|
||||||
|
|
||||||
|
db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video_array)
|
||||||
end
|
end
|
||||||
|
|
||||||
return video
|
return video
|
||||||
|
@ -590,8 +592,9 @@ def fetch_channel(ucid, client, db, pull_all_videos = true)
|
||||||
|
|
||||||
video_array = video.to_a
|
video_array = video.to_a
|
||||||
args = arg_array(video_array)
|
args = arg_array(video_array)
|
||||||
db.exec("INSERT INTO channel_videos VALUES (#{args})\
|
db.exec("INSERT INTO channel_videos VALUES (#{args}) \
|
||||||
ON CONFLICT (id) DO NOTHING", video_array)
|
ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \
|
||||||
|
updated = $4, ucid = $5, author = $6", video_array)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
videos = [] of ChannelVideo
|
videos = [] of ChannelVideo
|
||||||
|
|
Loading…
Reference in a new issue