summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-06-08 10:18:45 -0500
committerOmar Roth <omarroth@protonmail.com>2019-06-08 10:18:45 -0500
commitef8c9f093c0b6ea4b68b116d683e8d7f045ccd66 (patch)
treee910439f3584febb1c45bcd17e9c7cd651d4a84d
parent801dffd571ea9b0789da00fd0cfb2aae70e4e352 (diff)
downloadinvidious-ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66.tar.gz
invidious-ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66.tar.bz2
invidious-ef8c9f093c0b6ea4b68b116d683e8d7f045ccd66.zip
Add premiere date to watch page
-rw-r--r--assets/js/player.js37
-rw-r--r--locales/ar.json1
-rw-r--r--locales/de.json3
-rw-r--r--locales/el.json1
-rw-r--r--locales/en-US.json1
-rw-r--r--locales/eo.json3
-rw-r--r--locales/es.json1
-rw-r--r--locales/fr.json1
-rw-r--r--locales/nb_NO.json3
-rw-r--r--locales/nl.json3
-rw-r--r--locales/pl.json1
-rw-r--r--locales/ru.json1
-rw-r--r--locales/uk.json1
-rw-r--r--src/invidious.cr2
-rw-r--r--src/invidious/videos.cr8
-rw-r--r--src/invidious/views/embed.ecr3
-rw-r--r--src/invidious/views/watch.ecr13
17 files changed, 55 insertions, 28 deletions
diff --git a/assets/js/player.js b/assets/js/player.js
index 2b546ff4..8854d859 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -163,27 +163,28 @@ player.on('waiting', function () {
}
});
+if (video_data.premiere_timestamp && Math.round(new Date() / 1000) < video_data.premiere_timestamp) {
+ player.getChild('bigPlayButton').hide();
+}
+
if (video_data.params.autoplay) {
var bpb = player.getChild('bigPlayButton');
-
- if (bpb) {
- bpb.hide();
-
- player.ready(function () {
- new Promise(function (resolve, reject) {
- setTimeout(() => resolve(1), 1);
- }).then(function (result) {
- var promise = player.play();
-
- if (promise !== undefined) {
- promise.then(_ => {
- }).catch(error => {
- bpb.show();
- });
- }
- });
+ bpb.hide();
+
+ player.ready(function () {
+ new Promise(function (resolve, reject) {
+ setTimeout(() => resolve(1), 1);
+ }).then(function (result) {
+ var promise = player.play();
+
+ if (promise !== undefined) {
+ promise.then(_ => {
+ }).catch(error => {
+ bpb.show();
+ });
+ }
});
- }
+ });
}
if (!video_data.params.listen && video_data.params.quality === 'dash') {
diff --git a/locales/ar.json b/locales/ar.json
index 68380236..cc24da4a 100644
--- a/locales/ar.json
+++ b/locales/ar.json
@@ -136,6 +136,7 @@
"Shared `x`": "شارك منذ `x`",
"`x` views": "`x` مشاهدون",
"Premieres in `x`": "يعرض فى `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "اهلا! يبدو ان الجافاسكريبت معطلة. اضغط هنا لعرض التعليقات, ضع فى إعتبارك انها ستأخذ وقت اطول للعرض.",
"View YouTube comments": "عرض تعليقات اليوتيوب",
"View more comments on Reddit": "عرض المزيد من التعليقات على\\من موقع Reddit",
diff --git a/locales/de.json b/locales/de.json
index 6092fd94..e833ce69 100644
--- a/locales/de.json
+++ b/locales/de.json
@@ -136,6 +136,7 @@
"Shared `x`": "Geteilt `x`",
"`x` views": "`x` Ansichten",
"Premieres in `x`": "Premieren in `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hallo! Anscheinend haben Sie JavaScript deaktiviert. Klicken Sie hier um Kommentare anzuzeigen, beachten sie dass es etwas länger dauern kann um sie zu laden.",
"View YouTube comments": "YouTube Kommentare anzeigen",
"View more comments on Reddit": "Mehr Kommentare auf Reddit anzeigen",
@@ -315,4 +316,4 @@
"Videos": "Videos",
"Playlists": "Wiedergabelisten",
"Current version: ": "Aktuelle Version: "
-}
+} \ No newline at end of file
diff --git a/locales/el.json b/locales/el.json
index 54d514cb..3ed49c67 100644
--- a/locales/el.json
+++ b/locales/el.json
@@ -154,6 +154,7 @@
"": "`x` προβολές"
},
"Premieres in `x`": "Πρώτη προβολή σε `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Γεια! Φαίνεται πως έχετε απενεργοποιήσει το JavaScript. Πατήστε εδώ για προβολή σχολίων, αλλά έχετε υπ'όψιν σας πως ίσως φορτώσουν πιο αργά. ",
"View YouTube comments": "Προβολή σχολίων από το YouTube",
"View more comments on Reddit": "Προβολή περισσότερων σχολίων στο Reddit",
diff --git a/locales/en-US.json b/locales/en-US.json
index 1ca2b970..9b786260 100644
--- a/locales/en-US.json
+++ b/locales/en-US.json
@@ -154,6 +154,7 @@
"": "`x` views"
},
"Premieres in `x`": "Premieres in `x`",
+ "Premieres `x`": "Premieres `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.",
"View YouTube comments": "View YouTube comments",
"View more comments on Reddit": "View more comments on Reddit",
diff --git a/locales/eo.json b/locales/eo.json
index bdc6c0bf..bbaf128f 100644
--- a/locales/eo.json
+++ b/locales/eo.json
@@ -136,6 +136,7 @@
"Shared `x`": "Konigita `x`",
"`x` views": "`x` spektaĵoj",
"Premieres in `x`": "Premieras en `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Saluton! Ŝajnas, ke vi havas Ĝavoskripton malebligitan. Klaku ĉi tie por vidi komentojn, memoru, ke la ŝargado povus daŭri iom pli.",
"View YouTube comments": "Vidi komentojn de YouTube",
"View more comments on Reddit": "Vidi pli komentoj en Reddit",
@@ -315,4 +316,4 @@
"Videos": "Videoj",
"Playlists": "Ludlistoj",
"Current version: ": "Nuna versio: "
-}
+} \ No newline at end of file
diff --git a/locales/es.json b/locales/es.json
index e0fac8a2..10fbf5ca 100644
--- a/locales/es.json
+++ b/locales/es.json
@@ -136,6 +136,7 @@
"Shared `x`": "Compartido `x`",
"`x` views": "`x` visualizaciones",
"Premieres in `x`": "Se estrena en `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "¡Hola! Parece que tiene JavaScript desactivado. Haga clic aquí para ver los comentarios, pero tenga en cuenta que pueden tardar un poco más en cargarse.",
"View YouTube comments": "Ver los comentarios de YouTube",
"View more comments on Reddit": "Ver más comentarios en Reddit",
diff --git a/locales/fr.json b/locales/fr.json
index e2d586ae..72b12e92 100644
--- a/locales/fr.json
+++ b/locales/fr.json
@@ -136,6 +136,7 @@
"Shared `x`": "Ajoutée le `x`",
"`x` views": "`x` vues",
"Premieres in `x`": "Première dans `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Il semblerait que JavaScript soit désactivé. Cliquez ici pour voir les commentaires sans. Gardez à l'esprit que le chargement peut prendre plus de temps.",
"View YouTube comments": "Voir les commentaires YouTube",
"View more comments on Reddit": "Voir plus de commentaires sur Reddit",
diff --git a/locales/nb_NO.json b/locales/nb_NO.json
index acde88b6..e33004cd 100644
--- a/locales/nb_NO.json
+++ b/locales/nb_NO.json
@@ -136,6 +136,7 @@
"Shared `x`": "Delt `x`",
"`x` views": "`x` visninger",
"Premieres in `x`": "Premiere om `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hei. Det ser ut til at du har JavaScript avslått. Klikk her for å vise kommentarer, ha i minnet at innlasting tar lengre tid.",
"View YouTube comments": "Vis YouTube-kommentarer",
"View more comments on Reddit": "Vis flere kommenterer på Reddit",
@@ -315,4 +316,4 @@
"Videos": "Videoer",
"Playlists": "Spillelister",
"Current version: ": "Nåværende versjon: "
-}
+} \ No newline at end of file
diff --git a/locales/nl.json b/locales/nl.json
index 2cc716ef..d5a4907e 100644
--- a/locales/nl.json
+++ b/locales/nl.json
@@ -136,6 +136,7 @@
"Shared `x`": "`x` gedeeld",
"`x` views": "`x` weergaven",
"Premieres in `x`": "Verschijnt over `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hoi! Het lijkt erop dat je JavaScript hebt uitgeschakeld. Klik hier om de reacties te bekijken. Let op: het laden duurt wat langer.",
"View YouTube comments": "YouTube-reacties tonen",
"View more comments on Reddit": "Meer reacties bekijken op Reddit",
@@ -315,4 +316,4 @@
"Videos": "Video's",
"Playlists": "Afspeellijsten",
"Current version: ": "Huidige versie: "
-}
+} \ No newline at end of file
diff --git a/locales/pl.json b/locales/pl.json
index fa4ec965..52875f03 100644
--- a/locales/pl.json
+++ b/locales/pl.json
@@ -136,6 +136,7 @@
"Shared `x`": "Udostępniono `x`",
"`x` views": "`x` wyświetleń",
"Premieres in `x`": "Publikacja za `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Cześć! Wygląda na to, że masz wyłączoną obsługę JavaScriptu. Kliknij tutaj, żeby zobaczyć komentarze. Pamiętaj, że wczytywanie może potrwać dłużej.",
"View YouTube comments": "Wyświetl komentarze z YouTube",
"View more comments on Reddit": "Wyświetl więcej komentarzy na Reddicie",
diff --git a/locales/ru.json b/locales/ru.json
index e603b98f..b51589f4 100644
--- a/locales/ru.json
+++ b/locales/ru.json
@@ -136,6 +136,7 @@
"Shared `x`": "Опубликовано `x`",
"`x` views": "`x` просмотров",
"Premieres in `x`": "Премьера через `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Похоже, у вас отключён JavaScript. Чтобы увидить комментарии, нажмите сюда, но учтите: они могут загружаться немного медленнее.",
"View YouTube comments": "Смотреть комментарии с YouTube",
"View more comments on Reddit": "Посмотреть больше комментариев на Reddit",
diff --git a/locales/uk.json b/locales/uk.json
index 319f22d7..1bc281e9 100644
--- a/locales/uk.json
+++ b/locales/uk.json
@@ -136,6 +136,7 @@
"Shared `x`": "Розміщено `x`",
"`x` views": "`x` переглядів",
"Premieres in `x`": "Прем’єра через `x`",
+ "Premieres `x`": "",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Схоже, у вас відключений JavaScript. Щоб побачити коментарі, натисніть сюда, але майте на увазі, що вони можуть завантажуватися трохи довше.",
"View YouTube comments": "Переглянути коментарі з YouTube",
"View more comments on Reddit": "Переглянути більше коментарів на Reddit",
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>