diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-06-08 10:18:45 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-06-08 10:18:45 -0500 |
| commit | ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66 (patch) | |
| tree | e910439f3584febb1c45bcd17e9c7cd651d4a84d /src | |
| parent | 801dffd571ea9b0789da00fd0cfb2aae70e4e352 (diff) | |
| download | invidious-ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66.tar.gz invidious-ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66.tar.bz2 invidious-ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66.zip | |
Add premiere date to watch page
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 2 | ||||
| -rw-r--r-- | src/invidious/videos.cr | 8 | ||||
| -rw-r--r-- | src/invidious/views/embed.ecr | 3 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 13 |
4 files changed, 20 insertions, 6 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 63c44177..2ea2c518 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -519,7 +519,7 @@ get "/watch" do |env| engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100) playability_status = video.player_response["playabilityStatus"]? - if playability_status && playability_status["status"] == "LIVE_STREAM_OFFLINE" + if playability_status && playability_status["status"] == "LIVE_STREAM_OFFLINE" && !video.premiere_timestamp reason = playability_status["reason"]?.try &.as_s end reason ||= "" diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 5765d0c8..78a52db3 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -851,8 +851,12 @@ def get_video(id, db, proxies = {} of String => Array({ip: String, port: Int32}) if db.query_one?("SELECT EXISTS (SELECT true FROM videos WHERE id = $1)", id, as: Bool) && !region video = db.query_one("SELECT * FROM videos WHERE id = $1", id, as: Video) - # If record was last updated over 10 minutes ago, refresh (expire param in response lasts for 6 hours) - if (refresh && Time.utc - video.updated > 10.minutes) || force_refresh + # If record was last updated over 10 minutes ago, or video has since premiered, + # refresh (expire param in response lasts for 6 hours) + if (refresh && + (Time.utc - video.updated > 10.minutes) || + (video.premiere_timestamp && video.premiere_timestamp.as(Time) < Time.utc)) || + force_refresh begin video = fetch_video(id, proxies, region) video_array = video.to_a diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecr index b6307b9c..7fa5f45b 100644 --- a/src/invidious/views/embed.ecr +++ b/src/invidious/views/embed.ecr @@ -30,7 +30,8 @@ var video_data = { length_seconds: '<%= video.info["length_seconds"].to_f %>', video_series: <%= video_series.to_json %>, params: <%= params.to_json %>, - preferences: <%= preferences.to_json %> + preferences: <%= preferences.to_json %>, + premiere_timestamp: <%= video.premiere_timestamp.try &.to_unix || "null" %> } </script> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 2f03190a..85ca8b8b 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -40,7 +40,8 @@ var video_data = { hide_replies_text: '<%= HTML.escape(translate(locale, "Hide replies")) %>', show_replies_text: '<%= HTML.escape(translate(locale, "Show replies")) %>', params: <%= params.to_json %>, - preferences: <%= preferences.to_json %> + preferences: <%= preferences.to_json %>, + premiere_timestamp: <%= video.premiere_timestamp.try &.to_unix || "null" %> } </script> @@ -72,6 +73,10 @@ var video_data = { <h3> <%= reason %> </h3> + <% elsif video.premiere_timestamp %> + <h3> + <%= translate(locale, "Premieres in `x`", recode_date((video.premiere_timestamp.as(Time) - Time.utc).ago, locale)) %> + </h3> <% end %> </div> @@ -172,7 +177,11 @@ var video_data = { <%= rendered "components/subscribe_widget" %> <p> - <b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b> + <% if video.premiere_timestamp %> + <b><%= translate(locale, "Premieres `x`", video.premiere_timestamp.not_nil!.to_s("%B %-d, %R UTC")) %></b> + <% else %> + <b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b> + <% end %> </p> <div> |
