diff options
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | locales/de.json | 8 | ||||
| -rw-r--r-- | locales/eo.json | 4 | ||||
| -rw-r--r-- | locales/ru.json | 12 | ||||
| -rw-r--r-- | locales/uk.json | 12 | ||||
| -rw-r--r-- | src/invidious.cr | 41 | ||||
| -rw-r--r-- | src/invidious/comments.cr | 18 |
7 files changed, 70 insertions, 37 deletions
@@ -27,12 +27,16 @@ Patreon: https://patreon.com/omarroth BTC: 356DpZyMXu6rYd55Yqzjs29n79kGKWcYrY BCH: qq4ptclkzej5eza6a50et5ggc58hxsq5aylqut2npk -Onion links: +## Invidious Instances -- kgg2m7yk5aybusll.onion -- axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion +See [Invidious Instances](https://github.com/omarroth/invidious/wiki/Invidious-Instances) for a full list of publicly available instances. -[Alternative Invidious instances](https://github.com/omarroth/invidious/wiki/Invidious-Instances) +### Official Instances + +- [invidio.us](https://invidio.us) 🇺🇸 + Issuer: Let's Encrypt, [SSLLabs Verification](https://www.ssllabs.com/ssltest/analyze.html?d=invidio.us) +- [kgg2m7yk5aybusll.onion](http://kgg2m7yk5aybusll.onion) +- [axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion](http://axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion) ## Screenshots diff --git a/locales/de.json b/locales/de.json index e833ce69..3adbaec2 100644 --- a/locales/de.json +++ b/locales/de.json @@ -85,9 +85,9 @@ "Only show latest unwatched video from channel: ": "Nur neueste ungesehene Videos des Kanals anzeigen: ", "Only show unwatched: ": "Nur ungesehene anzeigen: ", "Only show notifications (if there are any): ": "Nur Benachrichtigungen anzeigen (wenn es welche gibt): ", - "Enable web notifications": "", - "`x` uploaded a video": "", - "`x` is live": "", + "Enable web notifications": "Webbenachrichtigungen aktivieren", + "`x` uploaded a video": "`x` hat ein Video hochgeladen", + "`x` is live": "`x` ist live", "Data preferences": "Dateneinstellungen", "Clear watch history": "Verlauf löschen", "Import/export data": "Daten im- exportieren", @@ -316,4 +316,4 @@ "Videos": "Videos", "Playlists": "Wiedergabelisten", "Current version: ": "Aktuelle Version: " -}
\ No newline at end of file +} diff --git a/locales/eo.json b/locales/eo.json index bbaf128f..3b15f3e3 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -136,7 +136,7 @@ "Shared `x`": "Konigita `x`", "`x` views": "`x` spektaĵoj", "Premieres in `x`": "Premieras en `x`", - "Premieres `x`": "", + "Premieres `x`": "Premieras `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", @@ -316,4 +316,4 @@ "Videos": "Videoj", "Playlists": "Ludlistoj", "Current version: ": "Nuna versio: " -}
\ No newline at end of file +} diff --git a/locales/ru.json b/locales/ru.json index b51589f4..0bee2a39 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -6,7 +6,7 @@ "Unsubscribe": "Отписаться", "Subscribe": "Подписаться", "View channel on YouTube": "Смотреть канал на YouTube", - "View playlist on YouTube": "", + "View playlist on YouTube": "Посмотреть плейлист на YouTube", "newest": "самые свежие", "oldest": "самые старые", "popular": "популярные", @@ -85,9 +85,9 @@ "Only show latest unwatched video from channel: ": "Показывать только непросмотренные видео с каналов: ", "Only show unwatched: ": "Показывать только непросмотренные видео: ", "Only show notifications (if there are any): ": "Показывать только оповещения, если они есть: ", - "Enable web notifications": "", - "`x` uploaded a video": "", - "`x` is live": "", + "Enable web notifications": "Включить уведомления в браузере", + "`x` uploaded a video": "`x` разместил видео", + "`x` is live": "`x` в прямом эфире", "Data preferences": "Настройки данных", "Clear watch history": "Очистить историю просмотров", "Import/export data": "Импорт/Экспорт данных", @@ -136,7 +136,7 @@ "Shared `x`": "Опубликовано `x`", "`x` views": "`x` просмотров", "Premieres in `x`": "Премьера через `x`", - "Premieres `x`": "", + "Premieres `x`": "Премьера `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", @@ -316,4 +316,4 @@ "Videos": "Видео", "Playlists": "Плейлисты", "Current version: ": "Текущая версия: " -}
\ No newline at end of file +} diff --git a/locales/uk.json b/locales/uk.json index 1bc281e9..c4632e9c 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -6,7 +6,7 @@ "Unsubscribe": "Відписатися", "Subscribe": "Підписатися", "View channel on YouTube": "Подивитися канал на YouTube", - "View playlist on YouTube": "", + "View playlist on YouTube": "Подивитися плейлист на YouTube", "newest": "найновіше", "oldest": "найстаріше", "popular": "популярне", @@ -85,9 +85,9 @@ "Only show latest unwatched video from channel: ": "Показувати тільки непереглянуті відео з каналів: ", "Only show unwatched: ": "Показувати тільки непереглянуті відео: ", "Only show notifications (if there are any): ": "Показувати лише сповіщення, якщо вони є: ", - "Enable web notifications": "", - "`x` uploaded a video": "", - "`x` is live": "", + "Enable web notifications": "Ввімкнути сповіщення в браузері", + "`x` uploaded a video": "`x` розмістив відео", + "`x` is live": "`x` у прямому ефірі", "Data preferences": "Налаштування даних", "Clear watch history": "Очистити історію переглядів", "Import/export data": "Імпорт і експорт даних", @@ -136,7 +136,7 @@ "Shared `x`": "Розміщено `x`", "`x` views": "`x` переглядів", "Premieres in `x`": "Прем’єра через `x`", - "Premieres `x`": "", + "Premieres `x`": "Прем’єра `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", @@ -316,4 +316,4 @@ "Videos": "Відео", "Playlists": "Плейлисти", "Current version: ": "Поточна версія: " -}
\ No newline at end of file +} diff --git a/src/invidious.cr b/src/invidious.cr index 8d50f815..3331d09f 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -340,6 +340,7 @@ get "/watch" do |env| if env.params.query["v"].empty? error_message = "Invalid parameters." + env.response.status_code = 400 next templated "error" end @@ -381,6 +382,7 @@ get "/watch" do |env| next env.redirect "/watch?v=#{ex.message}" rescue ex error_message = ex.message + env.response.status_code = 500 logger.puts("#{id} : #{ex.message}") next templated "error" end @@ -560,6 +562,7 @@ get "/embed/:id" do |env| videos = fetch_playlist_videos(plid, 1, 1, locale: locale) rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -602,6 +605,7 @@ get "/embed/:id" do |env| next env.redirect "/embed/#{ex.message}" rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -696,6 +700,7 @@ get "/playlist" do |env| playlist = fetch_playlist(plid, locale) rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -723,6 +728,7 @@ get "/mix" do |env| mix = fetch_mix(rdid, continuation, locale: locale) rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -843,6 +849,7 @@ get "/search" do |env| duration: duration, features: features) rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -864,6 +871,7 @@ get "/login" do |env| if !config.login_enabled error_message = "Login has been disabled by administrator." + env.response.status_code = 400 next templated "error" end @@ -892,6 +900,7 @@ post "/login" do |env| if !config.login_enabled error_message = "Login has been disabled by administrator." + env.response.status_code = 403 next templated "error" end @@ -965,11 +974,13 @@ post "/login" do |env| if challenge_results[0][3]?.try &.== 7 error_message = translate(locale, "Account has temporarily been disabled") + env.response.status_code = 423 next templated "error" end if challenge_results[0][-1]?.try &.[5] == "INCORRECT_ANSWER_ENTERED" error_message = translate(locale, "Incorrect password") + env.response.status_code = 401 next templated "error" end @@ -998,6 +1009,7 @@ post "/login" do |env| if tfa[2] == "TWO_STEP_VERIFICATION" if tfa[5] == "QUOTA_EXCEEDED" error_message = translate(locale, "Quota exceeded, try again in a few hours") + env.response.status_code = 423 next templated "error" end @@ -1031,6 +1043,7 @@ post "/login" do |env| }.to_json else error_message = translate(locale, "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.") + env.response.status_code = 500 next templated "error" end @@ -1043,6 +1056,7 @@ post "/login" do |env| if (challenge_results[0][-1]?.try &.[5] == "INCORRECT_ANSWER_ENTERED") || (challenge_results[0][-1]?.try &.[5] == "INVALID_INPUT") error_message = translate(locale, "Invalid TFA code") + env.response.status_code = 401 next templated "error" end @@ -1117,16 +1131,19 @@ post "/login" do |env| traceback.rewind # error_message = translate(locale, "Login failed. This may be because two-factor authentication is not turned on for your account.") error_message = %(#{ex.message}<br/>Traceback:<br/><div style="padding-left:2em" id="traceback">#{traceback.gets_to_end}</div>) + env.response.status_code = 500 next templated "error" end when "invidious" if !email error_message = translate(locale, "User ID is a required field") + env.response.status_code = 401 next templated "error" end if !password error_message = translate(locale, "Password is a required field") + env.response.status_code = 401 next templated "error" end @@ -1135,6 +1152,7 @@ post "/login" do |env| if user if !user.password error_message = translate(locale, "Please sign in using 'Log in with Google'") + env.response.status_code = 400 next templated "error" end @@ -1157,6 +1175,7 @@ post "/login" do |env| end else error_message = translate(locale, "Wrong username or password") + env.response.status_code = 401 next templated "error" end @@ -1169,17 +1188,20 @@ post "/login" do |env| else if !config.registration_enabled error_message = "Registration has been disabled by administrator." + env.response.status_code = 400 next templated "error" end if password.empty? error_message = translate(locale, "Password cannot be empty") + env.response.status_code = 401 next templated "error" end # See https://security.stackexchange.com/a/39851 if password.bytesize > 55 error_message = translate(locale, "Password should not be longer than 55 characters") + env.response.status_code = 400 next templated "error" end @@ -1241,6 +1263,7 @@ post "/login" do |env| end if !found_valid_captcha + env.response.status_code = 500 next templated "error" end end @@ -2050,6 +2073,7 @@ post "/change_password" do |env| # We don't store passwords for Google accounts if !user.password error_message = "Cannot change password for Google accounts" + env.response.status_code = 400 next templated "error" end @@ -2064,6 +2088,7 @@ post "/change_password" do |env| password = env.params.body["password"]? if !password error_message = translate(locale, "Password is a required field") + env.response.status_code = 401 next templated "error" end @@ -2071,22 +2096,26 @@ post "/change_password" do |env| if new_passwords.size <= 1 || new_passwords.uniq.size != 1 error_message = translate(locale, "New passwords must match") + env.response.status_code = 400 next templated "error" end new_password = new_passwords.uniq[0] if new_password.empty? error_message = translate(locale, "Password cannot be empty") + env.response.status_code = 401 next templated "error" end - if new_password.size > 55 - error_message = translate(locale, "Password cannot be longer than 55 characters") + if new_password.bytesize > 55 + error_message = translate(locale, "Password should not be longer than 55 characters") + env.response.status_code = 400 next templated "error" end - if !Crypto::Bcrypt::Password.new(user.password.not_nil!).verify(password) + if !Crypto::Bcrypt::Password.new(user.password.not_nil!).verify(password.byte_slice(0, 55)) error_message = translate(locale, "Incorrect password") + env.response.status_code = 401 next templated "error" end @@ -2317,6 +2346,7 @@ post "/token_ajax" do |env| rescue ex if redirect error_message = ex.message + env.response.status_code = 400 next templated "error" else error_message = {"error" => ex.message}.to_json @@ -2378,6 +2408,7 @@ get "/feed/trending" do |env| trending, plid = fetch_trending(trending_type, proxies, region, locale) rescue ex error_message = "#{ex.message}" + env.response.status_code = 500 next templated "error" end @@ -2854,6 +2885,7 @@ get "/channel/:ucid" do |env| author, ucid, auto_generated, sub_count = get_about_info(ucid, locale) rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -2923,6 +2955,7 @@ get "/channel/:ucid/playlists" do |env| author, ucid, auto_generated, sub_count = get_about_info(ucid, locale) rescue ex error_message = ex.message + env.response.status_code = 500 next templated "error" end @@ -3869,7 +3902,7 @@ get "/api/v1/playlists/:plid" do |env| playlist = fetch_playlist(plid, locale) rescue ex error_message = {"error" => "Playlist is empty"}.to_json - env.response.status_code = 500 + env.response.status_code = 410 next error_message end diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 7f1b010d..7f593760 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -114,7 +114,10 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m comments = JSON.build do |json| json.object do if body["header"]? - comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["simpleText"].as_s.delete("Comments,").to_i + count_text = body["header"]["commentsHeaderRenderer"]["countText"] + comment_count = (count_text["simpleText"]? || count_text["runs"]?.try &.[0]?.try &.["text"]?) + .try &.as_s.gsub(/\D/, "").to_i? || 0 + json.field "commentCount", comment_count end @@ -140,9 +143,7 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m content_html = node_comment["contentText"]["simpleText"]?.try &.as_s.rchop('\ufeff').try { |block| HTML.escape(block) }.to_s || content_to_comment_html(node_comment["contentText"]["runs"].as_a).try &.to_s || "" - - author = node_comment["authorText"]?.try &.["simpleText"] - author ||= "" + author = node_comment["authorText"]?.try &.["simpleText"]? || "" json.field "author", author json.field "authorThumbnails" do @@ -193,13 +194,8 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m end if node_replies && !response["commentRepliesContinuation"]? - reply_count = node_replies["moreText"]["simpleText"].as_s.delete("View all reply replies,") - if reply_count.empty? - reply_count = 1 - else - reply_count = reply_count.try &.to_i? - reply_count ||= 1 - end + reply_count = (node_replies["moreText"]["simpleText"]? || node_replies["moreText"]["runs"]?.try &.[0]?.try &.["text"]?) + .try &.as_s.gsub(/\D/, "").to_i? || 1 continuation = node_replies["continuations"]?.try &.as_a[0]["nextContinuationData"]["continuation"].as_s continuation ||= "" |
