mirror of
https://github.com/iv-org/invidious.git
synced 2026-08-17 05:20:51 -05:00
Preserve channel video publication times
This commit is contained in:
parent
fc52b5fd8b
commit
867f4fce82
@ -192,7 +192,9 @@ def fetch_channel(ucid, pull_all_videos : Bool)
|
||||
|
||||
# We don't include the 'premiere_timestamp' here because channel pages don't include them,
|
||||
# meaning the above timestamp is always null
|
||||
was_insert = Invidious::Database::ChannelVideos.insert(video)
|
||||
# InnerTube provides relative publication labels. Once persisted, keep the
|
||||
# existing timestamp so a later refresh cannot shift it forward.
|
||||
was_insert = Invidious::Database::ChannelVideos.insert(video, update_published: false)
|
||||
|
||||
if was_insert
|
||||
LOGGER.trace("fetch_channel: #{ucid} : video #{channel_video.id} : Inserted, updating subscriptions")
|
||||
@ -226,7 +228,7 @@ def fetch_channel(ucid, pull_all_videos : Bool)
|
||||
# We are notified of Red videos elsewhere (PubSub), which includes a correct published date,
|
||||
# so since they don't provide a published date here we can safely ignore them.
|
||||
if Time.utc - video.published > 1.minute
|
||||
was_insert = Invidious::Database::ChannelVideos.insert(video)
|
||||
was_insert = Invidious::Database::ChannelVideos.insert(video, update_published: false)
|
||||
if was_insert
|
||||
NOTIFICATION_CHANNEL.send(VideoNotification.from_video(video))
|
||||
end
|
||||
|
||||
@ -98,18 +98,20 @@ module Invidious::Database::ChannelVideos
|
||||
# -------------------
|
||||
|
||||
# This function returns the status of the query (i.e: success?)
|
||||
def insert(video : ChannelVideo, with_premiere_timestamp : Bool = false) : Bool
|
||||
def insert(video : ChannelVideo, with_premiere_timestamp : Bool = false, update_published : Bool = true) : Bool
|
||||
if with_premiere_timestamp
|
||||
last_items = "premiere_timestamp = $9, views = $10"
|
||||
else
|
||||
last_items = "views = $10"
|
||||
end
|
||||
|
||||
published_item = update_published ? "published = $3," : ""
|
||||
|
||||
request = <<-SQL
|
||||
INSERT INTO channel_videos
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||
ON CONFLICT (id) DO UPDATE
|
||||
SET title = $2, published = $3, updated = $4, ucid = $5,
|
||||
SET title = $2, #{published_item} updated = $4, ucid = $5,
|
||||
author = $6, length_seconds = $7, live_now = $8, #{last_items}
|
||||
RETURNING (xmax=0) AS was_insert
|
||||
SQL
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user