mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-19 12:44:23 -05:00
Clean up fetch_channel
This commit is contained in:
parent
7757eca92c
commit
0e30ddb728
@ -218,7 +218,7 @@ def get_video(id, client, db, refresh = true)
|
|||||||
# If record was last updated over an hour ago, refresh (expire param in response lasts for 6 hours)
|
# If record was last updated over an hour ago, refresh (expire param in response lasts for 6 hours)
|
||||||
if refresh && Time.now - video.updated > 1.hour
|
if refresh && Time.now - video.updated > 1.hour
|
||||||
begin
|
begin
|
||||||
video = fetch_video(id, client)
|
video = fetch_video(id, client)
|
||||||
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)
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ def get_video(id, client, db, refresh = true)
|
|||||||
= (#{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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
video = fetch_video(id, client)
|
video = fetch_video(id, client)
|
||||||
@ -540,12 +540,12 @@ def fetch_channel(id, client, db)
|
|||||||
|
|
||||||
video = ChannelVideo.new(video_id, title, published, updated, ucid, author)
|
video = ChannelVideo.new(video_id, title, published, updated, ucid, author)
|
||||||
|
|
||||||
video_array = video.to_a[1..-1]
|
video_array = video.to_a
|
||||||
args = arg_array(video_array)
|
args = arg_array(video_array)
|
||||||
|
|
||||||
# TODO: Update record on conflict
|
# TODO: Update record on conflict
|
||||||
db.exec("INSERT INTO channel_videos VALUES (#{arg_array(video.to_a)})\
|
db.exec("INSERT INTO channel_videos VALUES (#{args})\
|
||||||
ON CONFLICT (id) DO NOTHING", video.to_a)
|
ON CONFLICT (id) DO NOTHING", video_array)
|
||||||
end
|
end
|
||||||
|
|
||||||
author = rss.xpath_node("//feed/author/name").not_nil!.content
|
author = rss.xpath_node("//feed/author/name").not_nil!.content
|
||||||
@ -563,7 +563,7 @@ def get_user(sid, client, headers, db)
|
|||||||
user = fetch_user(sid, client, headers)
|
user = fetch_user(sid, client, headers)
|
||||||
user_array = user.to_a
|
user_array = user.to_a
|
||||||
args = arg_array(user_array)
|
args = arg_array(user_array)
|
||||||
|
|
||||||
db.exec("INSERT INTO users VALUES (#{args}) \
|
db.exec("INSERT INTO users VALUES (#{args}) \
|
||||||
ON CONFLICT (id) DO UPDATE SET updated = $2, subscriptions = $4", user_array)
|
ON CONFLICT (id) DO UPDATE SET updated = $2, subscriptions = $4", user_array)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user