Add premiere date to watch page

This commit is contained in:
Omar Roth 2019-06-08 10:18:45 -05:00
parent 801dffd571
commit ef8c9f093c
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2
17 changed files with 53 additions and 26 deletions

View File

@ -163,10 +163,12 @@ 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) { if (video_data.params.autoplay) {
var bpb = player.getChild('bigPlayButton'); var bpb = player.getChild('bigPlayButton');
if (bpb) {
bpb.hide(); bpb.hide();
player.ready(function () { player.ready(function () {
@ -184,7 +186,6 @@ if (video_data.params.autoplay) {
}); });
}); });
} }
}
if (!video_data.params.listen && video_data.params.quality === 'dash') { if (!video_data.params.listen && video_data.params.quality === 'dash') {
player.httpSourceSelector(); player.httpSourceSelector();

View File

@ -136,6 +136,7 @@
"Shared `x`": "شارك منذ `x`", "Shared `x`": "شارك منذ `x`",
"`x` views": "`x` مشاهدون", "`x` views": "`x` مشاهدون",
"Premieres in `x`": "يعرض فى `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.": "اهلا! يبدو ان الجافاسكريبت معطلة. اضغط هنا لعرض التعليقات, ضع فى إعتبارك انها ستأخذ وقت اطول للعرض.", "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": "عرض المزيد من التعليقات على\\من موقع Reddit", "View more comments on Reddit": "عرض المزيد من التعليقات على\\من موقع Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Geteilt `x`", "Shared `x`": "Geteilt `x`",
"`x` views": "`x` Ansichten", "`x` views": "`x` Ansichten",
"Premieres in `x`": "Premieren in `x`", "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.", "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 YouTube comments": "YouTube Kommentare anzeigen",
"View more comments on Reddit": "Mehr Kommentare auf Reddit anzeigen", "View more comments on Reddit": "Mehr Kommentare auf Reddit anzeigen",

View File

@ -154,6 +154,7 @@
"": "`x` προβολές" "": "`x` προβολές"
}, },
"Premieres in `x`": "Πρώτη προβολή σε `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. Πατήστε εδώ για προβολή σχολίων, αλλά έχετε υπ'όψιν σας πως ίσως φορτώσουν πιο αργά. ", "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 YouTube comments": "Προβολή σχολίων από το YouTube",
"View more comments on Reddit": "Προβολή περισσότερων σχολίων στο Reddit", "View more comments on Reddit": "Προβολή περισσότερων σχολίων στο Reddit",

View File

@ -154,6 +154,7 @@
"": "`x` views" "": "`x` views"
}, },
"Premieres in `x`": "Premieres in `x`", "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.", "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 YouTube comments": "View YouTube comments",
"View more comments on Reddit": "View more comments on Reddit", "View more comments on Reddit": "View more comments on Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Konigita `x`", "Shared `x`": "Konigita `x`",
"`x` views": "`x` spektaĵoj", "`x` views": "`x` spektaĵoj",
"Premieres in `x`": "Premieras en `x`", "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.", "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 YouTube comments": "Vidi komentojn de YouTube",
"View more comments on Reddit": "Vidi pli komentoj en Reddit", "View more comments on Reddit": "Vidi pli komentoj en Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Compartido `x`", "Shared `x`": "Compartido `x`",
"`x` views": "`x` visualizaciones", "`x` views": "`x` visualizaciones",
"Premieres in `x`": "Se estrena en `x`", "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.", "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 YouTube comments": "Ver los comentarios de YouTube",
"View more comments on Reddit": "Ver más comentarios en Reddit", "View more comments on Reddit": "Ver más comentarios en Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Ajoutée le `x`", "Shared `x`": "Ajoutée le `x`",
"`x` views": "`x` vues", "`x` views": "`x` vues",
"Premieres in `x`": "Première dans `x`", "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.", "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 YouTube comments": "Voir les commentaires YouTube",
"View more comments on Reddit": "Voir plus de commentaires sur Reddit", "View more comments on Reddit": "Voir plus de commentaires sur Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Delt `x`", "Shared `x`": "Delt `x`",
"`x` views": "`x` visninger", "`x` views": "`x` visninger",
"Premieres in `x`": "Premiere om `x`", "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.", "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 YouTube comments": "Vis YouTube-kommentarer",
"View more comments on Reddit": "Vis flere kommenterer på Reddit", "View more comments on Reddit": "Vis flere kommenterer på Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "`x` gedeeld", "Shared `x`": "`x` gedeeld",
"`x` views": "`x` weergaven", "`x` views": "`x` weergaven",
"Premieres in `x`": "Verschijnt over `x`", "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.", "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 YouTube comments": "YouTube-reacties tonen",
"View more comments on Reddit": "Meer reacties bekijken op Reddit", "View more comments on Reddit": "Meer reacties bekijken op Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Udostępniono `x`", "Shared `x`": "Udostępniono `x`",
"`x` views": "`x` wyświetleń", "`x` views": "`x` wyświetleń",
"Premieres in `x`": "Publikacja za `x`", "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.", "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 YouTube comments": "Wyświetl komentarze z YouTube",
"View more comments on Reddit": "Wyświetl więcej komentarzy na Reddicie", "View more comments on Reddit": "Wyświetl więcej komentarzy na Reddicie",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Опубликовано `x`", "Shared `x`": "Опубликовано `x`",
"`x` views": "`x` просмотров", "`x` views": "`x` просмотров",
"Premieres in `x`": "Премьера через `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. Чтобы увидить комментарии, нажмите сюда, но учтите: они могут загружаться немного медленнее.", "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 YouTube comments": "Смотреть комментарии с YouTube",
"View more comments on Reddit": "Посмотреть больше комментариев на Reddit", "View more comments on Reddit": "Посмотреть больше комментариев на Reddit",

View File

@ -136,6 +136,7 @@
"Shared `x`": "Розміщено `x`", "Shared `x`": "Розміщено `x`",
"`x` views": "`x` переглядів", "`x` views": "`x` переглядів",
"Premieres in `x`": "Прем’єра через `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. Щоб побачити коментарі, натисніть сюда, але майте на увазі, що вони можуть завантажуватися трохи довше.", "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 YouTube comments": "Переглянути коментарі з YouTube",
"View more comments on Reddit": "Переглянути більше коментарів на Reddit", "View more comments on Reddit": "Переглянути більше коментарів на Reddit",

View File

@ -519,7 +519,7 @@ get "/watch" do |env|
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100) engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
playability_status = video.player_response["playabilityStatus"]? 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 reason = playability_status["reason"]?.try &.as_s
end end
reason ||= "" reason ||= ""

View File

@ -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 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) 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 record was last updated over 10 minutes ago, or video has since premiered,
if (refresh && Time.utc - video.updated > 10.minutes) || force_refresh # 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 begin
video = fetch_video(id, proxies, region) video = fetch_video(id, proxies, region)
video_array = video.to_a video_array = video.to_a

View File

@ -30,7 +30,8 @@ var video_data = {
length_seconds: '<%= video.info["length_seconds"].to_f %>', length_seconds: '<%= video.info["length_seconds"].to_f %>',
video_series: <%= video_series.to_json %>, video_series: <%= video_series.to_json %>,
params: <%= params.to_json %>, params: <%= params.to_json %>,
preferences: <%= preferences.to_json %> preferences: <%= preferences.to_json %>,
premiere_timestamp: <%= video.premiere_timestamp.try &.to_unix || "null" %>
} }
</script> </script>

View File

@ -40,7 +40,8 @@ var video_data = {
hide_replies_text: '<%= HTML.escape(translate(locale, "Hide replies")) %>', hide_replies_text: '<%= HTML.escape(translate(locale, "Hide replies")) %>',
show_replies_text: '<%= HTML.escape(translate(locale, "Show replies")) %>', show_replies_text: '<%= HTML.escape(translate(locale, "Show replies")) %>',
params: <%= params.to_json %>, params: <%= params.to_json %>,
preferences: <%= preferences.to_json %> preferences: <%= preferences.to_json %>,
premiere_timestamp: <%= video.premiere_timestamp.try &.to_unix || "null" %>
} }
</script> </script>
@ -72,6 +73,10 @@ var video_data = {
<h3> <h3>
<%= reason %> <%= reason %>
</h3> </h3>
<% elsif video.premiere_timestamp %>
<h3>
<%= translate(locale, "Premieres in `x`", recode_date((video.premiere_timestamp.as(Time) - Time.utc).ago, locale)) %>
</h3>
<% end %> <% end %>
</div> </div>
@ -172,7 +177,11 @@ var video_data = {
<%= rendered "components/subscribe_widget" %> <%= rendered "components/subscribe_widget" %>
<p> <p>
<% 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> <b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b>
<% end %>
</p> </p>
<div> <div>