From 065c104f274b88495dc331f32dd3dc1cf2c99646 Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 24 May 2021 06:45:50 -0700 Subject: [PATCH 1/8] Upgrade to crystal 1.0.0 --- shard.lock | 18 +++++++----------- shard.yml | 11 ++++------- src/invidious.cr | 2 +- src/invidious/helpers/utils.cr | 8 ++++---- src/invidious/jobs/bypass_captcha_job.cr | 2 +- src/invidious/routes/login.cr | 4 ++-- src/invidious/routes/preferences.cr | 8 ++++---- src/invidious/users.cr | 2 +- 8 files changed, 24 insertions(+), 31 deletions(-) diff --git a/shard.lock b/shard.lock index 5ed730b8..9a087f7a 100644 --- a/shard.lock +++ b/shard.lock @@ -2,19 +2,19 @@ version: 2.0 shards: db: git: https://github.com/crystal-lang/crystal-db.git - version: 0.10.0 + version: 0.10.1 exception_page: git: https://github.com/crystal-loot/exception_page.git - version: 0.1.4 + version: 0.1.5 kemal: git: https://github.com/kemalcr/kemal.git - version: 0.27.0 + version: 1.0.0 kilt: git: https://github.com/jeromegn/kilt.git - version: 0.4.0 + version: 0.4.1 lsquic: git: https://github.com/iv-org/lsquic.cr.git @@ -22,19 +22,15 @@ shards: pg: git: https://github.com/will/crystal-pg.git - version: 0.23.1 - - pool: - git: https://github.com/ysbaddaden/pool.git - version: 0.2.3 + version: 0.23.2 protodec: git: https://github.com/iv-org/protodec.git - version: 0.1.3 + version: 0.1.4 radix: git: https://github.com/luislavena/radix.git - version: 0.3.9 + version: 0.4.1 sqlite3: git: https://github.com/crystal-lang/crystal-sqlite3.git diff --git a/shard.yml b/shard.yml index a15b3ea5..f7746cb5 100644 --- a/shard.yml +++ b/shard.yml @@ -12,23 +12,20 @@ targets: dependencies: pg: github: will/crystal-pg - version: ~> 0.23.1 + version: ~> 0.23.2 sqlite3: github: crystal-lang/crystal-sqlite3 version: ~> 0.18.0 kemal: github: kemalcr/kemal - version: ~> 0.27.0 - pool: - github: ysbaddaden/pool - version: ~> 0.2.3 + version: ~> 1.0.0 protodec: github: iv-org/protodec - version: ~> 0.1.3 + version: ~> 0.1.4 lsquic: github: iv-org/lsquic.cr version: ~> 2.18.1-1 -crystal: 0.36.1 +crystal: 1.0.0 license: AGPLv3 diff --git a/src/invidious.cr b/src/invidious.cr index ae20e13e..de89b9c3 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -421,7 +421,7 @@ get "/modify_notifications" do |env| html = YT_POOL.client &.get("/subscription_manager?disable_polymer=1", headers) - cookies = HTTP::Cookies.from_headers(headers) + cookies = HTTP::Cookies.from_client_headers(headers) html.cookies.each do |cookie| if {"VISITOR_INFO1_LIVE", "YSC", "SIDCC"}.includes? cookie.name if cookies[cookie.name]? diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 10d4e6b6..20107fad 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -1,5 +1,5 @@ require "lsquic" -require "pool/connection" +require "db" def add_yt_headers(request) request.headers["user-agent"] ||= "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36" @@ -20,7 +20,7 @@ struct YoutubeConnectionPool property! url : URI property! capacity : Int32 property! timeout : Float64 - property pool : ConnectionPool(QUIC::Client | HTTP::Client) + property pool : DB::Pool(QUIC::Client | HTTP::Client) def initialize(url : URI, @capacity = 5, @timeout = 5.0, use_quic = true) @url = url @@ -43,7 +43,7 @@ struct YoutubeConnectionPool conn.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com" response = yield conn ensure - pool.checkin(conn) + pool.release(conn) end end @@ -51,7 +51,7 @@ struct YoutubeConnectionPool end private def build_pool(use_quic) - ConnectionPool(QUIC::Client | HTTP::Client).new(capacity: capacity, timeout: timeout) do + DB::Pool(QUIC::Client | HTTP::Client).new(initial_pool_size: 0, max_pool_size: capacity, max_idle_pool_size: capacity, checkout_timeout: timeout) do if use_quic conn = QUIC::Client.new(url) else diff --git a/src/invidious/jobs/bypass_captcha_job.cr b/src/invidious/jobs/bypass_captcha_job.cr index 4269e123..e68b81e6 100644 --- a/src/invidious/jobs/bypass_captcha_job.cr +++ b/src/invidious/jobs/bypass_captcha_job.cr @@ -112,7 +112,7 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJob headers = HTTP::Headers{ "Cookie" => URI.parse(response.headers["location"]).query_params["google_abuse"].split(";")[0], } - cookies = HTTP::Cookies.from_headers(headers) + cookies = HTTP::Cookies.from_client_headers(headers) cookies.each { |cookie| CONFIG.cookies << cookie } diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr index ffe5f568..f9e6ea6c 100644 --- a/src/invidious/routes/login.cr +++ b/src/invidious/routes/login.cr @@ -238,7 +238,7 @@ class Invidious::Routes::Login < Invidious::Routes::BaseRoute traceback << "Logging in..." location = URI.parse(challenge_results[0][-1][2].to_s) - cookies = HTTP::Cookies.from_headers(headers) + cookies = HTTP::Cookies.from_client_headers(headers) headers.delete("Content-Type") headers.delete("Google-Accounts-XSRF") @@ -261,7 +261,7 @@ class Invidious::Routes::Login < Invidious::Routes::BaseRoute location = login.headers["Location"]?.try { |u| URI.parse(u) } end - cookies = HTTP::Cookies.from_headers(headers) + cookies = HTTP::Cookies.from_client_headers(headers) sid = cookies["SID"]?.try &.value if !sid raise "Couldn't get SID." diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index cfdad443..f98c7a5e 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -198,10 +198,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute end if CONFIG.domain - env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: preferences, expires: Time.utc + 2.years, + env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years, secure: secure, http_only: true) else - env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.utc + 2.years, + env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years, secure: secure, http_only: true) end end @@ -250,10 +250,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute end if CONFIG.domain - env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: preferences, expires: Time.utc + 2.years, + env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years, secure: secure, http_only: true) else - env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.utc + 2.years, + env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years, secure: secure, http_only: true) end end diff --git a/src/invidious/users.cr b/src/invidious/users.cr index 5dfd80bb..d774ee12 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -462,7 +462,7 @@ def subscribe_ajax(channel_id, action, env_headers) html = YT_POOL.client &.get("/subscription_manager?disable_polymer=1", headers) - cookies = HTTP::Cookies.from_headers(headers) + cookies = HTTP::Cookies.from_client_headers(headers) html.cookies.each do |cookie| if {"VISITOR_INFO1_LIVE", "YSC", "SIDCC"}.includes? cookie.name if cookies[cookie.name]? From 0a87ba6930948ebfec9a3ad2e336c0c7e6037d8a Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 24 May 2021 06:52:55 -0700 Subject: [PATCH 2/8] Decode URL encoded preference cookie when parsing --- src/invidious.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index de89b9c3..ebba52b1 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -166,7 +166,7 @@ end before_all do |env| preferences = begin - Preferences.from_json(env.request.cookies["PREFS"]?.try &.value || "{}") + Preferences.from_json(URI.decode_www_form(env.request.cookies["PREFS"]?.try &.value || "{}")) rescue Preferences.from_json("{}") end From 392a363d02142026f717f44381b043f199918489 Mon Sep 17 00:00:00 2001 From: syeopite Date: Tue, 8 Jun 2021 13:20:46 -0700 Subject: [PATCH 3/8] Update Dockerfile for crystal 1.0 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 87884403..b8e5af8a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM crystallang/crystal:0.36.1-alpine AS builder +FROM crystallang/crystal:1.0.0-alpine AS builder RUN apk add --no-cache curl sqlite-static yaml-static WORKDIR /invidious COPY ./shard.yml ./shard.yml From 114cac99e781aefb54b5d377fcebb2d6c6274417 Mon Sep 17 00:00:00 2001 From: syeopite Date: Wed, 9 Jun 2021 16:34:54 -0700 Subject: [PATCH 4/8] Update CI's crystal version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66aacff9..54e70d0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Install Crystal uses: oprypin/install-crystal@v1.2.4 with: - crystal: 0.36.1 + crystal: 1.0.0 - name: Cache Shards uses: actions/cache@v2 From 8701de64cebc64860ebcf00262ac0d44d01b0a90 Mon Sep 17 00:00:00 2001 From: syeopite Date: Thu, 10 Jun 2021 04:49:19 -0700 Subject: [PATCH 5/8] Bump lsquic.cr shard version to v2.18.1-2 --- shard.lock | 2 +- shard.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shard.lock b/shard.lock index 9a087f7a..35d1aefd 100644 --- a/shard.lock +++ b/shard.lock @@ -18,7 +18,7 @@ shards: lsquic: git: https://github.com/iv-org/lsquic.cr.git - version: 2.18.1-1 + version: 2.18.1-2 pg: git: https://github.com/will/crystal-pg.git diff --git a/shard.yml b/shard.yml index f7746cb5..fca1ce02 100644 --- a/shard.yml +++ b/shard.yml @@ -24,7 +24,7 @@ dependencies: version: ~> 0.1.4 lsquic: github: iv-org/lsquic.cr - version: ~> 2.18.1-1 + version: ~> 2.18.1-2 crystal: 1.0.0 From 5f8e47a14dc2ad148a8049c1a96cb4929af5645b Mon Sep 17 00:00:00 2001 From: syeopite <70992037+syeopite@users.noreply.github.com> Date: Fri, 11 Jun 2021 01:38:54 -0700 Subject: [PATCH 6/8] Temporarily remove thread locker comments --- .github/workflows/lock.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index a0a181c5..afed2240 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -18,5 +18,5 @@ jobs: issue-lock-reason: 'resolved' pr-lock-reason: 'resolved' - issue-lock-comment: 'This issue has been automatically locked since there has not been any activity in it in the last 30 days. If this is still applicable to the current version of Invidious feel free to open a new issue.' - pr-lock-comment: 'This pull request has been automatically locked since there has not been any activity in it in the last 30 days. If you want to tell us about needed or wanted changes or if problems related to this code are discovered, feel free to open an issue or a new pull request.' + # issue-lock-comment: 'This issue has been automatically locked since there has not been any activity in it in the last 30 days. If this is still applicable to the current version of Invidious feel free to open a new issue.' + # pr-lock-comment: 'This pull request has been automatically locked since there has not been any activity in it in the last 30 days. If you want to tell us about needed or wanted changes or if problems related to this code are discovered, feel free to open an issue or a new pull request.' From f0bd0abc0fdacbf13fd1dcc68dec4d877ffbfbea Mon Sep 17 00:00:00 2001 From: Benedek Nagy Date: Fri, 11 Jun 2021 09:28:11 +0000 Subject: [PATCH 7/8] Update Hungarian translation --- locales/hu-HU.json | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 29817cc2..97f03648 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -68,8 +68,8 @@ "Fallback captions: ": "Másodlagos feliratok: ", "Show related videos: ": "Kapcsolódó videók mutatása: ", "Show annotations by default: ": "Annotációk mutatása alapértelmetésben: ", - "Automatically extend video description: ": "", - "Interactive 360 degree videos: ": "", + "Automatically extend video description: ": "Automatikusan jelenítse meg a videó teljes leírását: ", + "Interactive 360 degree videos: ": "Interaktív 360 fokos vidók: ", "Visual preferences": "Vizuális preferenciák", "Player style: ": "Lejátszó stílusa: ", "Dark mode: ": "Sötét mód: ", @@ -140,8 +140,8 @@ "Title": "Címe", "Playlist privacy": "Lejátszási lista láthatósága", "Editing playlist `x`": "`x` lista szerkesztése", - "Show more": "", - "Show less": "", + "Show more": "Több mutatása", + "Show less": "Kevesebb mutatása", "Watch on YouTube": "Megtekintés a YouTube-on", "Hide annotations": "Annotációk elrejtése", "Show annotations": "Annotációk mutatása", @@ -156,7 +156,7 @@ "`x` views": "`x` megtekintés", "Premieres in `x`": "Premier `x`", "Premieres `x`": "Premier `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.": "Hello! Úgy tűnik, hogy a JavaScript nincs engedélyezve a böngésződben. Kattints ide a kommentek megtekintéséhez. Ezek betöltése kissé tovább tarthat.", "View YouTube comments": "YouTube kommentek megtekintése", "View more comments on Reddit": "További Reddit kommentek megtekintése", "View `x` comments": "`x` komment megtekintése", @@ -200,22 +200,22 @@ "Token is expired, please try again": "Lejárt token, kérem próbáld újra", "English": "angol", "English (auto-generated)": "angol (automatikusan generált)", - "Afrikaans": "", - "Albanian": "", - "Amharic": "", - "Arabic": "", - "Armenian": "", - "Azerbaijani": "", - "Bangla": "", - "Basque": "", - "Belarusian": "", - "Bosnian": "", - "Bulgarian": "", - "Burmese": "", - "Catalan": "", - "Cebuano": "", - "Chinese (Simplified)": "", - "Chinese (Traditional)": "", + "Afrikaans": "afrikaans", + "Albanian": "albán", + "Amharic": "amhara", + "Arabic": "arab", + "Armenian": "örmény", + "Azerbaijani": "azerbajdzsáni", + "Bangla": "bengáli", + "Basque": "baszk", + "Belarusian": "fehérorosz", + "Bosnian": "bosnyák", + "Bulgarian": "bolgár", + "Burmese": "burmai", + "Catalan": "katalán", + "Cebuano": "szebuano", + "Chinese (Simplified)": "kínai (egyszerűsített)", + "Chinese (Traditional)": "kínai (hagyományos)", "Corsican": "", "Croatian": "", "Czech": "", From 992125febc36b94cd9f4f27e2a3197e54fca6669 Mon Sep 17 00:00:00 2001 From: Reza Almanda Date: Thu, 10 Jun 2021 01:31:24 +0000 Subject: [PATCH 8/8] Update Indonesian translation --- locales/id.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/locales/id.json b/locales/id.json index 440b0015..ce98f87b 100644 --- a/locales/id.json +++ b/locales/id.json @@ -1,15 +1,15 @@ { "`x` subscribers": { "([^.,0-9]|^)1([^.,0-9]|$)": "`x` pelanggan", - "": "`x` pelanggan" + "": "`x` pelanggan." }, "`x` videos": { "([^.,0-9]|^)1([^.,0-9]|$)": "`x` video", - "": "`x` video" + "": "`x` video." }, "`x` playlists": { "([^.,0-9]|^)1([^.,0-9]|$)": "`x` daftar putar", - "": "`x` daftar putar" + "": "`x` daftar putar." }, "LIVE": "SIARAN LANGSUNG", "Shared `x` ago": "Dibagikan`x` lalu", @@ -77,7 +77,7 @@ "Fallback captions: ": "Subtitel fallback: ", "Show related videos: ": "Tampilkan video terkait: ", "Show annotations by default: ": "Tampilkan anotasi secara default: ", - "Automatically extend video description: ": "Luaskan keterangan video secara matis: ", + "Automatically extend video description: ": "Perluas deskripsi video secara otomatis: ", "Interactive 360 degree videos: ": "Video interaktif 360°: ", "Visual preferences": "Preferensi visual", "Player style: ": "Gaya pemutar: ", @@ -126,11 +126,11 @@ "Token": "Token", "`x` subscriptions": { "([^.,0-9]|^)1([^.,0-9]|$)": "`x` langganan", - "": "`x` langganan" + "": "`x` langganan." }, "`x` tokens": { "([^.,0-9]|^)1([^.,0-9]|$)": "`x` token", - "": "`x` token" + "": "`x` token." }, "Import/export": "Impor/ekspor", "unsubscribe": "batal langganan", @@ -138,7 +138,7 @@ "Subscriptions": "Langganan", "`x` unseen notifications": { "([^.,0-9]|^)1([^.,0-9]|$)": "`x` pemberitahuan belum dilihat", - "": "`x` pemberitahuan belum dilihat" + "": "`x` pemberitahuan belum dilihat." }, "search": "cari", "Log out": "Keluar", @@ -158,8 +158,8 @@ "Title": "Judul", "Playlist privacy": "Privasi daftar putar", "Editing playlist `x`": "Menyunting daftar putar `x`", - "Show more": "Tampil lebih", - "Show less": "Tampil kurang", + "Show more": "Tampilkan lainnya", + "Show less": "Tampilkan lebih sedikit", "Watch on YouTube": "Tonton di YouTube", "Hide annotations": "Sembunyikan anotasi", "Show annotations": "Tampilkan anotasi", @@ -363,7 +363,7 @@ "([^.,0-9]|^)1([^.,0-9]|$)": "`x` detik.([^.,0-9]|^)1([^.,0-9]|$)", "": "`x` detik." }, - "Fallback comments: ": "Komentar ganti: ", + "Fallback comments: ": "Komentar mundur: ", "Popular": "Populer", "Search": "Cari", "Top": "Teratas", @@ -373,7 +373,7 @@ "View as playlist": "Tampilkan sebagai daftar putar", "Default": "Asali", "Music": "Musik", - "Gaming": "Gaming", + "Gaming": "Permainan", "News": "Berita", "Movies": "Film", "Download": "Unduh",