diff options
| -rw-r--r-- | locales/ar.json | 3 | ||||
| -rw-r--r-- | locales/de.json | 3 | ||||
| -rw-r--r-- | locales/el.json | 7 | ||||
| -rw-r--r-- | locales/en-US.json | 93 | ||||
| -rw-r--r-- | locales/eo.json | 3 | ||||
| -rw-r--r-- | locales/es.json | 1 | ||||
| -rw-r--r-- | locales/eu.json | 3 | ||||
| -rw-r--r-- | locales/fr.json | 3 | ||||
| -rw-r--r-- | locales/it.json | 3 | ||||
| -rw-r--r-- | locales/nb_NO.json | 3 | ||||
| -rw-r--r-- | locales/nl.json | 3 | ||||
| -rw-r--r-- | locales/pl.json | 1 | ||||
| -rw-r--r-- | locales/ru.json | 3 | ||||
| -rw-r--r-- | locales/uk.json | 3 | ||||
| -rw-r--r-- | src/invidious.cr | 4 | ||||
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 2 | ||||
| -rw-r--r-- | src/invidious/helpers/jobs.cr | 78 | ||||
| -rw-r--r-- | src/invidious/views/playlist.ecr | 16 |
18 files changed, 155 insertions, 77 deletions
diff --git a/locales/ar.json b/locales/ar.json index 6bd14722..9e077242 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -6,6 +6,7 @@ "Unsubscribe": "إلغاء الإشتراك", "Subscribe": "إشتراك", "View channel on YouTube": "زيارة القناة على موقع يوتيوب", + "View playlist on YouTube": "", "newest": "الأجدد", "oldest": "الأقدم", "popular": "الاكثر شعبية", @@ -311,4 +312,4 @@ "Videos": "الفيديوهات", "Playlists": "قوائم التشغيل", "Current version: ": "الإصدار الحالى" -} +}
\ No newline at end of file diff --git a/locales/de.json b/locales/de.json index 79ac958d..4e243c4e 100644 --- a/locales/de.json +++ b/locales/de.json @@ -6,6 +6,7 @@ "Unsubscribe": "Abbestellen", "Subscribe": "Abonnieren", "View channel on YouTube": "Kanal auf YouTube anzeigen", + "View playlist on YouTube": "", "newest": "neueste", "oldest": "älteste", "popular": "beliebt", @@ -311,4 +312,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 9aa1f6cc..7a12d2df 100644 --- a/locales/el.json +++ b/locales/el.json @@ -12,6 +12,7 @@ "Unsubscribe": "Απεγγραφή", "Subscribe": "Εγγραφή", "View channel on YouTube": "Προβολή καναλιού στο YouTube", + "View playlist on YouTube": "", "newest": "νεότερα", "oldest": "παλιότερα", "popular": "δημοφιλή", @@ -172,8 +173,8 @@ "Password cannot be empty": "Ο κωδικός πρόσβασης δεν γίνεται να είναι κενός", "Password cannot be longer than 55 characters": "Ο κωδικός πρόσβασης δεν γίνεται να υπερβαίνει τους 55 χαρακτήρες", "Please log in": "Συνδεθείτε", - "Invidious Private Feed for `x`": "Ροή RSS του Invidious για το χρήστη `x`", - "channel:`x`": "κανάλι:`x`", + "Invidious Private Feed for `x`": "Ροή RSS του Invidious για το χρήστη `x`", + "channel:`x`": "κανάλι:`x`", "Deleted or invalid channel": "Διαγραμμένο ή μη έγκυρο κανάλι", "This channel does not exist.": "Αυτό το κανάλι δεν υπάρχει.", "Could not get channel info.": "Αδύναμια εύρεσης πληροφοριών καναλιού.", @@ -356,4 +357,4 @@ "Videos": "Βίντεο", "Playlists": "Λίστες Αναπαραγωγής", "Current version: ": "Τρέχουσα έκδοση: " -} +}
\ No newline at end of file diff --git a/locales/en-US.json b/locales/en-US.json index c6774647..5f6245f5 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -1,13 +1,18 @@ { - "`x` subscribers.(\\D|^)1(\\D|$)": "`x` subscriber", - "`x` subscribers.": "`x` subscribers.", - "`x` videos.(\\D|^)1(\\D|$)": "`x` video", - "`x` videos.": "`x` videos.", + "`x` subscribers": { + "(\\D|^)1(\\D|$)": "`x` subscriber", + "": "`x` subscribers" + }, + "`x` videos": { + "(\\D|^)1(\\D|$)": "`x` video", + "": "`x` videos" + }, "LIVE": "LIVE", "Shared `x` ago": "Shared `x` ago", "Unsubscribe": "Unsubscribe", "Subscribe": "Subscribe", "View channel on YouTube": "View channel on YouTube", + "View playlist on YouTube": "View playlist on YouTube", "newest": "newest", "oldest": "oldest", "popular": "popular", @@ -106,16 +111,22 @@ "Subscription manager": "Subscription manager", "Token manager": "Token manager", "Token": "Token", - "`x` subscriptions.(\\D|^)1(\\D|$)": "`x` subscription", - "`x` subscriptions.": "`x` subscriptions.", - "`x` tokens.(\\D|^)1(\\D|$)": "`x` token", - "`x` tokens.": "`x` tokens.", + "`x` subscriptions": { + "(\\D|^)1(\\D|$)": "`x` subscription", + "": "`x` subscriptions" + }, + "`x` tokens": { + "(\\D|^)1(\\D|$)": "`x` token", + "": "`x` tokens" + }, "Import/export": "Import/export", "unsubscribe": "unsubscribe", "revoke": "revoke", "Subscriptions": "Subscriptions", - "`x` unseen notifications.(\\D|^)1(\\D|$)": "`x` unseen notification", - "`x` unseen notifications.": "`x` unseen notifications.", + "`x` unseen notifications": { + "(\\D|^)1(\\D|$)": "`x` unseen notification", + "": "`x` unseen notifications" + }, "search": "search", "Log out": "Log out", "Released under the AGPLv3 by Omar Roth.": "Released under the AGPLv3 by Omar Roth.", @@ -135,8 +146,10 @@ "Whitelisted regions: ": "Whitelisted regions: ", "Blacklisted regions: ": "Blacklisted regions: ", "Shared `x`": "Shared `x`", - "`x` views.(\\D|^)1(\\D|$)": "`x` views", - "`x` views.": "`x` views.", + "`x` views": { + "(\\D|^)1(\\D|$)": "`x` views", + "": "`x` views" + }, "Premieres in `x`": "Premieres in `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", @@ -166,12 +179,16 @@ "This channel does not exist.": "This channel does not exist.", "Could not get channel info.": "Could not get channel info.", "Could not fetch comments": "Could not fetch comments", - "View `x` replies.(\\D|^)1(\\D|$)": "View `x` reply", - "View `x` replies.": "View `x` replies.", + "View `x` replies": { + "(\\D|^)1(\\D|$)": "View `x` reply", + "": "View `x` replies" + }, "`x` ago": "`x` ago", "Load more": "Load more", - "`x` points.(\\D|^)1(\\D|$)": "`x` point", - "`x` points.": "`x` points.", + "`x` points": { + "(\\D|^)1(\\D|$)": "`x` point", + "": "`x` points" + }, "Could not create mix.": "Could not create mix.", "Empty playlist": "Empty playlist", "Not a playlist.": "Not a playlist.", @@ -289,20 +306,34 @@ "Yiddish": "Yiddish", "Yoruba": "Yoruba", "Zulu": "Zulu", - "`x` years.(\\D|^)1(\\D|$)": "`x` year", - "`x` years.": "`x` years.", - "`x` months.(\\D|^)1(\\D|$)": "`x` month", - "`x` months.": "`x` months.", - "`x` weeks.(\\D|^)1(\\D|$)": "`x` week", - "`x` weeks.": "`x` weeks.", - "`x` days.(\\D|^)1(\\D|$)": "`x` day", - "`x` days.": "`x` days.", - "`x` hours.(\\D|^)1(\\D|$)": "`x` hour", - "`x` hours.": "`x` hours.", - "`x` minutes.(\\D|^)1(\\D|$)": "`x` minute", - "`x` minutes.": "`x` minutes.", - "`x` seconds.(\\D|^)1(\\D|$)": "`x` second", - "`x` seconds.": "`x` seconds.", + "`x` years": { + "(\\D|^)1(\\D|$)": "`x` year", + "": "`x` years" + }, + "`x` months": { + "(\\D|^)1(\\D|$)": "`x` month", + "": "`x` months" + }, + "`x` weeks": { + "(\\D|^)1(\\D|$)": "`x` week", + "": "`x` weeks" + }, + "`x` days": { + "(\\D|^)1(\\D|$)": "`x` day", + "": "`x` days" + }, + "`x` hours": { + "(\\D|^)1(\\D|$)": "`x` hour", + "": "`x` hours" + }, + "`x` minutes": { + "(\\D|^)1(\\D|$)": "`x` minute", + "": "`x` minutes" + }, + "`x` seconds": { + "(\\D|^)1(\\D|$)": "`x` second", + "": "`x` seconds" + }, "Fallback comments: ": "Fallback comments: ", "Popular": "Popular", "Top": "Top", @@ -326,4 +357,4 @@ "Videos": "Videos", "Playlists": "Playlists", "Current version: ": "Current version: " -} +}
\ No newline at end of file diff --git a/locales/eo.json b/locales/eo.json index 461c22c5..3f06c790 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -6,6 +6,7 @@ "Unsubscribe": "Malaboni", "Subscribe": "Aboni", "View channel on YouTube": "Vidi kanalon en YouTube", + "View playlist on YouTube": "", "newest": "pli novaj", "oldest": "pli malnovaj", "popular": "popularaj", @@ -311,4 +312,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 efdc6739..2f6d8560 100644 --- a/locales/es.json +++ b/locales/es.json @@ -6,6 +6,7 @@ "Unsubscribe": "Desuscribirse", "Subscribe": "Suscribirse", "View channel on YouTube": "Ver el canal en YouTube", + "View playlist on YouTube": "", "newest": "más nuevos", "oldest": "más viejos", "popular": "populares", diff --git a/locales/eu.json b/locales/eu.json index c064f727..aae43603 100644 --- a/locales/eu.json +++ b/locales/eu.json @@ -6,6 +6,7 @@ "Unsubscribe": "Harpidetza kendu", "Subscribe": "Harpidetu", "View channel on YouTube": "Ikusi kanala YouTuben", + "View playlist on YouTube": "", "newest": "berrienak", "oldest": "zaharrenak", "popular": "ospetsuenak", @@ -309,4 +310,4 @@ "Audio mode": "", "Video mode": "", "Videos": "" -} +}
\ No newline at end of file diff --git a/locales/fr.json b/locales/fr.json index f3e10833..9f042480 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -6,6 +6,7 @@ "Unsubscribe": "Se désabonner", "Subscribe": "S'abonner", "View channel on YouTube": "Voir la chaîne sur YouTube", + "View playlist on YouTube": "", "newest": "Date d'ajout (la plus récente)", "oldest": "Date d'ajout (la plus ancienne)", "popular": "Les plus populaires", @@ -311,4 +312,4 @@ "Videos": "Vidéos", "Playlists": "Liste de lecture", "Current version: ": "Version actuelle : " -} +}
\ No newline at end of file diff --git a/locales/it.json b/locales/it.json index eb071c38..10527f9f 100644 --- a/locales/it.json +++ b/locales/it.json @@ -6,6 +6,7 @@ "Unsubscribe": "Disiscriviti", "Subscribe": "Iscriviti", "View channel on YouTube": "Vedi canale su YouTube", + "View playlist on YouTube": "", "newest": "Data di aggiunta (più recente)", "oldest": "Data di aggiunta (più vecchia)", "popular": "Tendenze", @@ -311,4 +312,4 @@ "Videos": "", "Playlists": "", "Current version: ": "" -} +}
\ No newline at end of file diff --git a/locales/nb_NO.json b/locales/nb_NO.json index d7ff101c..63492245 100644 --- a/locales/nb_NO.json +++ b/locales/nb_NO.json @@ -6,6 +6,7 @@ "Unsubscribe": "Opphev abonnement", "Subscribe": "Abonner", "View channel on YouTube": "Vis kanal på YouTube", + "View playlist on YouTube": "", "newest": "nyeste", "oldest": "eldste", "popular": "populært", @@ -311,4 +312,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 7367fc34..06bc8f0c 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -6,6 +6,7 @@ "Unsubscribe": "Abonnement opzeggen", "Subscribe": "Abonneren", "View channel on YouTube": "Bekijk kanaal op Youtube", + "View playlist on YouTube": "", "newest": "nieuwste", "oldest": "oudste", "popular": "populair", @@ -311,4 +312,4 @@ "Videos": "", "Playlists": "", "Current version: ": "" -} +}
\ No newline at end of file diff --git a/locales/pl.json b/locales/pl.json index c77098b5..621bdd76 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -6,6 +6,7 @@ "Unsubscribe": "Odsubskrybuj", "Subscribe": "Subskrybuj", "View channel on YouTube": "Wyświetl kanał na YouTube", + "View playlist on YouTube": "", "newest": "najnowsze", "oldest": "najstarsze", "popular": "popularne", diff --git a/locales/ru.json b/locales/ru.json index d1989d98..f9c56204 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -6,6 +6,7 @@ "Unsubscribe": "Отписаться", "Subscribe": "Подписаться", "View channel on YouTube": "Смотреть канал на YouTube", + "View playlist on YouTube": "", "newest": "самые свежие", "oldest": "самые старые", "popular": "популярные", @@ -311,4 +312,4 @@ "Videos": "Видео", "Playlists": "Плейлисты", "Current version: ": "Текущая версия: " -} +}
\ No newline at end of file diff --git a/locales/uk.json b/locales/uk.json index b79d29ab..e666e280 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -6,6 +6,7 @@ "Unsubscribe": "Відписатися", "Subscribe": "Підписатися", "View channel on YouTube": "Подивитися канал на YouTube", + "View playlist on YouTube": "", "newest": "найновіше", "oldest": "найстаріше", "popular": "популярне", @@ -311,4 +312,4 @@ "Videos": "Відео", "Playlists": "Плейлисти", "Current version: ": "Поточна версія: " -} +}
\ No newline at end of file diff --git a/src/invidious.cr b/src/invidious.cr index ad4401a7..f487b0e9 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -129,8 +129,8 @@ end # Start jobs -refresh_channels(PG_DB, logger, config.channel_threads, config.full_refresh) -refresh_feeds(PG_DB, logger, config.feed_threads, config.use_feed_events) +refresh_channels(PG_DB, logger, config) +refresh_feeds(PG_DB, logger, config) subscribe_to_feeds(PG_DB, logger, HMAC_KEY, config) statistics = { diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 983d3d1e..3155cb67 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -105,7 +105,7 @@ struct Config hmac_key: String?, # HMAC signing key for CSRF tokens and verifying pubsub subscriptions domain: String?, # Domain to be used for links to resources on the site where an absolute URL is required use_pubsub_feeds: {type: Bool | Int32, default: false}, # Subscribe to channels using PubSubHubbub (requires domain, hmac_key) - use_feed_events: {type: Bool, default: false}, # Update feeds on receiving notifications + use_feed_events: {type: Bool | Int32, default: false}, # Update feeds on receiving notifications default_home: {type: String, default: "Top"}, feed_menu: {type: Array(String), default: ["Popular", "Top", "Trending", "Subscriptions"]}, top_enabled: {type: Bool, default: true}, diff --git a/src/invidious/helpers/jobs.cr b/src/invidious/helpers/jobs.cr index d725a023..b9f9a86f 100644 --- a/src/invidious/helpers/jobs.cr +++ b/src/invidious/helpers/jobs.cr @@ -1,4 +1,4 @@ -def refresh_channels(db, logger, max_threads = 1, full_refresh = false) +def refresh_channels(db, logger, config) max_channel = Channel(Int32).new spawn do @@ -20,7 +20,7 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false) active_threads += 1 spawn do begin - channel = fetch_channel(id, db, full_refresh) + channel = fetch_channel(id, db, config.full_refresh) db.exec("UPDATE channels SET updated = $1, author = $2, deleted = false WHERE id = $3", Time.now, channel.author, id) rescue ex @@ -39,47 +39,71 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false) end end - max_channel.send(max_threads) + max_channel.send(config.channel_threads) end -def refresh_feeds(db, logger, max_threads = 1, use_feed_events = false) - max_channel = Channel(Int32).new - +def refresh_feeds(db, logger, config) # Spawn thread to handle feed events - if use_feed_events + if config.use_feed_events + case config.use_feed_events + when Bool + max_feed_event_threads = config.use_feed_events.as(Bool).to_unsafe + when Int32 + max_feed_event_threads = config.use_feed_events.as(Int32) + end + max_feed_event_channel = Channel(Int32).new + spawn do queue = Deque(String).new(30) + PG.connect_listen(PG_URL, "feeds") do |event| + if !queue.includes? event.payload + queue << event.payload + end + end - spawn do - loop do - if event = queue.shift? - feed = JSON.parse(event) - email = feed["email"].as_s - action = feed["action"].as_s + max_threads = max_feed_event_channel.receive + active_threads = 0 + active_channel = Channel(Bool).new - view_name = "subscriptions_#{sha256(email)}" + loop do + until queue.empty? + event = queue.shift - case action - when "refresh" - db.exec("REFRESH MATERIALIZED VIEW #{view_name}") + if active_threads >= max_threads + if active_channel.receive + active_threads -= 1 end - - # Delete any future events that we just processed - queue.delete(event) - else - sleep 1.second end - Fiber.yield + active_threads += 1 + + spawn do + begin + feed = JSON.parse(event) + email = feed["email"].as_s + action = feed["action"].as_s + + view_name = "subscriptions_#{sha256(email)}" + + case action + when "refresh" + db.exec("REFRESH MATERIALIZED VIEW #{view_name}") + end + rescue ex + end + + active_channel.send(true) + end end - end - PG.connect_listen(PG_URL, "feeds") do |event| - queue << event.payload + sleep 5.seconds end end + + max_feed_event_channel.send(max_feed_event_threads.as(Int32)) end + max_channel = Channel(Int32).new spawn do max_threads = max_channel.receive active_threads = 0 @@ -144,7 +168,7 @@ def refresh_feeds(db, logger, max_threads = 1, use_feed_events = false) end end - max_channel.send(max_threads) + max_channel.send(config.feed_threads) end def subscribe_to_feeds(db, logger, key, config) diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr index b43bd89c..f6921f9a 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -15,17 +15,27 @@ </div> <div class="pure-g h-box"> - <div class="pure-u-1 pure-u-md-1-4"> - <a href="/channel/<%= playlist.ucid %>"> - <b><%= playlist.author %></b> + <div class="pure-u-1-3"> + <a href="https://www.youtube.com/playlist?list=<%= playlist.id %>"> + <%= translate(locale, "View playlist on YouTube") %> </a> + <div class="pure-u-1 pure-md-1-3"> + <a href="/channel/<%= playlist.ucid %>"> + <b><%= playlist.author %></b> + </a> + </div> </div> + <div class="pure-u-1-2"></div> </div> <div class="h-box"> <p><%= playlist.description_html %></p> </div> +<div class="h-box"> + <hr> +</div> + <div class="pure-g"> <% videos.each_slice(4) do |slice| %> <% slice.each do |item| %> |
