Invidious is an alternative front-end to YouTube
Add view count to video items
Omar Rothb51fd7fc1325
diff --git a/locales/ar.json b/locales/ar.jsonindex e41ab16f..90747982 100644--- a/locales/ar.json+++ b/locales/ar.json@@ -5,7 +5,6 @@"Shared `x` ago": "تم رفع الفيديو منذ `x`","Unsubscribe": "إلغاء الإشتراك","Subscribe": "إشتراك",-"View channel on YouTube": "زيارة القناة على موقع يوتيوب","newest": "الأجدد","oldest": "الأقدم",@@ -115,6 +114,7 @@"Whitelisted regions: ": "الدول المسموح فيها هذا الفيديو: ","Blacklisted regions: ": "الدول الحظور فيها هذا الفيديو: ","Shared `x`": "شارك منذ `x`",+ "`x` views": "","Premieres in `x`": "يعرض فى 'x'","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "اهلا! يبدو ان الجافاسكريبت معطلة. اضغط هنا لعرض التعليقات, ضع فى إعتبارك انها ستأخذ وقت اطول للعرض.","View YouTube comments": "عرض تعليقات اليوتيوب",diff --git a/locales/de.json b/locales/de.jsonindex 6b3609e0..275e44e3 100644--- a/locales/de.json+++ b/locales/de.json@@ -5,7 +5,6 @@"Shared `x` ago": "Vor `x` geteilt","Unsubscribe": "Abbestellen","Subscribe": "Abonnieren",-"View channel on YouTube": "Kanal auf YouTube anzeigen","newest": "neueste","oldest": "älteste",@@ -115,6 +114,7 @@"Whitelisted regions: ": "Erlaubte Regionen: ","Blacklisted regions: ": "Unerlaubte Regionen: ","Shared `x`": "Geteilt `x`",+ "`x` views": "","Premieres in `x`": "","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it 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",diff --git a/locales/en-US.json b/locales/en-US.jsonindex 95012c36..7f5e3d3b 100644--- a/locales/en-US.json+++ b/locales/en-US.json@@ -5,7 +5,6 @@"Shared `x` ago": "Shared `x` ago","Unsubscribe": "Unsubscribe","Subscribe": "Subscribe",-"View channel on YouTube": "View channel on YouTube","newest": "newest","oldest": "oldest",@@ -103,7 +102,7 @@"View JavaScript license information.": "View JavaScript license information.","View privacy policy.": "View privacy policy.","Trending": "Trending",- "Unlisted": "",+ "Unlisted": "Unlisted","Watch video on Youtube": "Watch video on Youtube","Genre: ": "Genre: ","License: ": "License: ",@@ -113,7 +112,8 @@"Whitelisted regions: ": "Whitelisted regions: ","Blacklisted regions: ": "Blacklisted regions: ","Shared `x`": "Shared `x`",- "Premieres in `x`": "",+ "`x` views": "",+ "Premieres in `x`": "Premieres in `x`","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it 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/es.json b/locales/es.jsonindex 7ad32336..6c9cc7d5 100644--- a/locales/es.json+++ b/locales/es.json@@ -5,7 +5,6 @@"Shared `x` ago": "Compartido hace `x`","Unsubscribe": "Desuscribirse","Subscribe": "Suscribirse",-"View channel on YouTube": "Ver el canal en YouTube","newest": "más nuevos","oldest": "más viejos",@@ -113,6 +112,7 @@"Whitelisted regions: ": "Regiones permitidas: ","Blacklisted regions: ": "Regiones bloqueadas: ","Shared `x`": "Compartido `x`",+ "`x` views": "","Premieres in `x`": "","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it 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",diff --git a/locales/eu.json b/locales/eu.jsonindex 28dabd1a..5f9d5c09 100644--- a/locales/eu.json+++ b/locales/eu.json@@ -5,7 +5,6 @@"Shared `x` ago": "Duela `x` partekatua","Unsubscribe": "Harpidetza kendu","Subscribe": "Harpidetu",-"View channel on YouTube": "Ikusi kanala YouTuben","newest": "berrienak","oldest": "zaharrenak",@@ -113,6 +112,7 @@"Whitelisted regions: ": "","Blacklisted regions: ": "","Shared `x`": "",+ "`x` views": "","Premieres in `x`": "","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "","View YouTube comments": "",diff --git a/locales/fr.json b/locales/fr.jsonindex 6bbc6ff8..162ebe38 100644--- a/locales/fr.json+++ b/locales/fr.json@@ -5,7 +5,6 @@"Shared `x` ago": "Ajoutée il y a `x`","Unsubscribe": "Se désabonner","Subscribe": "S'abonner",-"View channel on YouTube": "Voir la chaîne sur YouTube","newest": "Date d'ajout (la plus récente)","oldest": "Date d'ajout (la plus ancienne)",@@ -113,6 +112,7 @@"Whitelisted regions: ": "Régions en liste blanche : ","Blacklisted regions: ": "Régions sur liste noire : ","Shared `x`": "Ajoutée le `x`",+ "`x` views": "","Premieres in `x`": "Première dans `x`","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it 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",diff --git a/locales/it.json b/locales/it.jsonindex c6706d6b..d67df287 100644--- a/locales/it.json+++ b/locales/it.json@@ -5,7 +5,6 @@"Shared `x` ago": "Condiviso `x` fa","Unsubscribe": "Disiscriviti","Subscribe": "Iscriviti",-"View channel on YouTube": "Vedi canale su YouTube","newest": "Data di aggiunta (più recente)","oldest": "Data di aggiunta (più vecchia)",@@ -113,6 +112,7 @@"Whitelisted regions: ": "Regioni nella lista bianca: ","Blacklisted regions: ": "Regioni nella lista nera: ","Shared `x`": "Condiviso `x`",+ "`x` views": "","Premieres in `x`": "","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "Ciao! Sembra che tu abbia disattivato JavaScript. Clicca qui per visualizzare i commenti. Considera che potrebbe volerci più tempo.","View YouTube comments": "Visualizza i commenti da YouTube",diff --git a/locales/nb_NO.json b/locales/nb_NO.jsonindex 9078bffd..926f3f91 100644--- a/locales/nb_NO.json+++ b/locales/nb_NO.json@@ -5,7 +5,6 @@"Shared `x` ago": "Delt for `x` siden","Unsubscribe": "Opphev abonnement","Subscribe": "Abonner",-"View channel on YouTube": "Vis kanal på YouTube","newest": "nyeste","oldest": "eldste",@@ -113,6 +112,7 @@"Whitelisted regions: ": "Hvitlistede regioner: ","Blacklisted regions: ": "Svartelistede regioner: ","Shared `x`": "Delt `x`",+ "`x` views": "","Premieres in `x`": "Premiere om `x`","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it 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",diff --git a/locales/nl.json b/locales/nl.jsonindex 8e0dd3de..4129f378 100644--- a/locales/nl.json+++ b/locales/nl.json@@ -5,7 +5,6 @@"Shared `x` ago": "Gedeeld `x` geleden","Unsubscribe": "Abonnement opzeggen","Subscribe": "Abonneren",-"View channel on YouTube": "Bekijk kanaal op Youtube","newest": "nieuwste","oldest": "oudste",@@ -113,6 +112,7 @@"Whitelisted regions: ": "Toegestane regio's: ","Blacklisted regions: ": "Geblokkeerde regio's: ","Shared `x`": "`x` gedeeld",+ "`x` views": "","Premieres in `x`": "","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "Hoi! Het lijkt erop dat je JavaScript uit hebt staan. Klik hier om de reacties te bekijken, hou er rekening mee dat het wat langer duurt om te laden.","View YouTube comments": "Bekijk YouTube reacties",diff --git a/locales/pl.json b/locales/pl.jsonindex 4fa8d5d7..ee883259 100644--- a/locales/pl.json+++ b/locales/pl.json@@ -5,7 +5,6 @@"Shared `x` ago": "Udostępniono `x` temu","Unsubscribe": "Odsubskrybuj","Subscribe": "Subskrybuj",-"View channel on YouTube": "Wyświetl kanał na YouTube","newest": "najnowsze","oldest": "najstarsze",@@ -113,6 +112,7 @@"Whitelisted regions: ": "Dostępny na obszarach: ","Blacklisted regions: ": "Niedostępny na obszarach: ","Shared `x`": "Udostępniono `x`",+ "`x` views": "","Premieres in `x`": "","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it 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",diff --git a/locales/ru.json b/locales/ru.jsonindex ce2355d7..811c01de 100644--- a/locales/ru.json+++ b/locales/ru.json@@ -5,7 +5,6 @@"Shared `x` ago": "Опубликовано `x` назад","Unsubscribe": "Отписаться","Subscribe": "Подписаться",-"View channel on YouTube": "Канал на YouTube","newest": "новые","oldest": "старые",@@ -115,6 +114,7 @@"Whitelisted regions: ": "Доступно для: ","Blacklisted regions: ": "Недоступно для: ","Shared `x`": "Опубликовано `x`",+ "`x` views": "","Premieres in `x`": "Премьера через `x`","Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "Похоже, что у Вас отключен JavaScript. Нажмите сюда, чтобы увидеть комментарии (учтите, что они могут загружаться дольше).","View YouTube comments": "Смотреть комментарии с YouTube",diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.crindex eb8fa80a..eb304d8d 100644--- a/src/invidious/helpers/utils.cr+++ b/src/invidious/helpers/utils.cr@@ -189,7 +189,9 @@ def number_to_short_text(number)text = text.rchop(".0")- if number / 1000000 != 0+ if number / 1_000_000_000 != 0+ text += "B"+ elsif number / 1_000_000 != 0text += "M"elsif number / 1000 != 0text += "K"diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecrindex e2a5195c..2dc0bea4 100644--- a/src/invidious/views/components/item.ecr+++ b/src/invidious/views/components/item.ecr@@ -71,7 +71,12 @@<% if item.responds_to?(:premiere_timestamp) && item.premiere_timestamp && item.premiere_timestamp.not_nil! > Time.now %><h5><%= translate(locale, "Premieres in `x`", recode_date((item.premiere_timestamp.as(Time) - Time.now).ago, locale)) %></h5><% elsif Time.now - item.published > 1.minute %>- <h5><%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %></h5>+ <h5 class="pure-g">+ <div class="pure-u-2-3"><%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %></div>+ <div class="pure-u-1-3" style="text-align: right">+ <%= item.responds_to?(:views) ? translate(locale, "`x` views", number_to_short_text(item.views)) : "" %>+ </div>+ </h5><% end %><% else %><% if env.get("preferences").as(Preferences).thin_mode %>@@ -108,7 +113,12 @@<% if item.responds_to?(:premiere_timestamp) && item.premiere_timestamp && item.premiere_timestamp.not_nil! > Time.now %><h5><%= translate(locale, "Premieres in `x`", recode_date((item.premiere_timestamp.as(Time) - Time.now).ago, locale)) %></h5><% elsif Time.now - item.published > 1.minute %>- <h5><%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %></h5>+ <h5 class="pure-g">+ <div class="pure-u-2-3"><%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %></div>+ <div class="pure-u-1-3" style="text-align: right">+ <%= item.responds_to?(:views) ? translate(locale, "`x` views", number_to_short_text(item.views)) : "" %>+ </div>+ </h5><% end %><% end %></div>