diff --git a/spec/helpers_spec.cr b/spec/helpers_spec.cr index f4dfdcd7..f731473b 100644 --- a/spec/helpers_spec.cr +++ b/spec/helpers_spec.cr @@ -17,17 +17,13 @@ CONFIG = Config.from_yaml(File.open("config/config.example.yml")) describe "Helper" do describe "#produce_channel_videos_url" do it "correctly produces url for requesting page `x` of a channel's videos" do - #produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw").should eq("/browse_ajax?continuation=4qmFsgI8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4&gl=JP&hl=ja") - produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw").should eq("/browse_ajax?continuation=4qmFsgI8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4&gl=US&hl=en") + produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw").should eq("/browse_ajax?continuation=4qmFsgI8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4&gl=JP&hl=en") - #produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFPQ%3D%3D&gl=JP&hl=ja") - produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFPQ%3D%3D&gl=US&hl=en") + produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFPQ%3D%3D&gl=JP&hl=en") - #produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20).should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUE9PQ%3D%3D&gl=JP&hl=ja") - produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20).should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUE9PQ%3D%3D&gl=US&hl=en") + produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20).should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUE9PQ%3D%3D&gl=JP&hl=en") - #produce_channel_videos_url(ucid: "UC-9-kyTW8ZkZNDHQJ6FgpwQ", page: 20, sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQy05LWt5VFc4WmtaTkRIUUo2Rmdwd1EaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUJnQg%3D%3D&gl=JP&hl=ja") - produce_channel_videos_url(ucid: "UC-9-kyTW8ZkZNDHQJ6FgpwQ", page: 20, sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQy05LWt5VFc4WmtaTkRIUUo2Rmdwd1EaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUJnQg%3D%3D&gl=US&hl=en") + produce_channel_videos_url(ucid: "UC-9-kyTW8ZkZNDHQJ6FgpwQ", page: 20, sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQy05LWt5VFc4WmtaTkRIUUo2Rmdwd1EaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUJnQg%3D%3D&gl=JP&hl=en") end end @@ -41,8 +37,7 @@ describe "Helper" do describe "#produce_channel_playlists_url" do it "correctly produces a /browse_ajax URL with the given UCID and cursor" do - produce_channel_playlists_url("UCCj956IF62FbT7Gouszaj9w", "AIOkY9EQpi_gyn1_QrFuZ1reN81_MMmI1YmlBblw8j7JHItEFG5h7qcJTNd4W9x5Quk_CVZ028gW").should eq("/browse_ajax?continuation=4qmFsgLNARIYVUNDajk1NklGNjJGYlQ3R291c3phajl3GrABRWdsd2JHRjViR2x6ZEhNd0FqZ0JZQUZxQUxnQkFIcG1VVlZzVUdFeGF6VlNWa1ozWVZZNWJtVlhOSGhZTVVaNVVtNVdZVTFZU214VWFtZDRXREF4VG1KVmEzaFhWekZ6VVcxS2MyUjZhSEZPTUhCSlUxaFNSbEpyWXpGaFJHUjRXVEJ3VlZSdFVUQldlbXcwVGxaR01XRXhPVVJXYkc5M1RXcG9ibFozSUFFWUF3PT0%3D&gl=JP&hl=ja") - produce_channel_playlists_url("UCCj956IF62FbT7Gouszaj9w", "AIOkY9EQpi_gyn1_QrFuZ1reN81_MMmI1YmlBblw8j7JHItEFG5h7qcJTNd4W9x5Quk_CVZ028gW").should eq("/browse_ajax?continuation=4qmFsgLNARIYVUNDajk1NklGNjJGYlQ3R291c3phajl3GrABRWdsd2JHRjViR2x6ZEhNd0FqZ0JZQUZxQUxnQkFIcG1VVlZzVUdFeGF6VlNWa1ozWVZZNWJtVlhOSGhZTVVaNVVtNVdZVTFZU214VWFtZDRXREF4VG1KVmEzaFhWekZ6VVcxS2MyUjZhSEZPTUhCSlUxaFNSbEpyWXpGaFJHUjRXVEJ3VlZSdFVUQldlbXcwVGxaR01XRXhPVVJXYkc5M1RXcG9ibFozSUFFWUF3PT0%3D&gl=US&hl=en") + produce_channel_playlists_url("UCCj956IF62FbT7Gouszaj9w", "AIOkY9EQpi_gyn1_QrFuZ1reN81_MMmI1YmlBblw8j7JHItEFG5h7qcJTNd4W9x5Quk_CVZ028gW").should eq("/browse_ajax?continuation=4qmFsgLNARIYVUNDajk1NklGNjJGYlQ3R291c3phajl3GrABRWdsd2JHRjViR2x6ZEhNd0FqZ0JZQUZxQUxnQkFIcG1VVlZzVUdFeGF6VlNWa1ozWVZZNWJtVlhOSGhZTVVaNVVtNVdZVTFZU214VWFtZDRXREF4VG1KVmEzaFhWekZ6VVcxS2MyUjZhSEZPTUhCSlUxaFNSbEpyWXpGaFJHUjRXVEJ3VlZSdFVUQldlbXcwVGxaR01XRXhPVVJXYkc5M1RXcG9ibFozSUFFWUF3PT0%3D&gl=JP&hl=en") end end diff --git a/src/invidious.cr b/src/invidious.cr index 9a143c09..e4fe995d 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -813,8 +813,7 @@ post "/data_control" do |env| if match = channel["url"].as_s.match(/\/channel\/(?UC[a-zA-Z0-9_-]{22})/) next match["channel"] elsif match = channel["url"].as_s.match(/\/user\/(?.+)/) - response = YT_POOL.client &.get("/user/#{match["user"]}?disable_polymer=1&hl=ja&gl=JP") - #response = YT_POOL.client &.get("/user/#{match["user"]}?disable_polymer=1&hl=en&gl=US") + response = YT_POOL.client &.get("/user/#{match["user"]}?disable_polymer=1&hl=en&gl=JP") html = XML.parse_html(response.body) ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] next ucid if ucid diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr index 18a2f21b..1a945f7b 100644 --- a/src/invidious/channels/about.cr +++ b/src/invidious/channels/about.cr @@ -29,11 +29,9 @@ struct AboutRelatedChannel end def get_about_info(ucid, locale) - #result = YT_POOL.client &.get("/channel/#{ucid}/about?gl=JP&hl=ja") - result = YT_POOL.client &.get("/channel/#{ucid}/about?gl=US&hl=en") + result = YT_POOL.client &.get("/channel/#{ucid}/about?gl=JP&hl=en") if result.status_code != 200 - #result = YT_POOL.client &.get("/user/#{ucid}/about?gl=JP&hl=ja") - result = YT_POOL.client &.get("/user/#{ucid}/about?gl=US&hl=en") + result = YT_POOL.client &.get("/user/#{ucid}/about?gl=JP&hl=en") end if md = result.headers["location"]?.try &.match(/\/channel\/(?UC[a-zA-Z0-9_-]{22})/) diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 34719a99..78915a0b 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -1,10 +1,8 @@ # TODO: Add "sort_by" def fetch_channel_community(ucid, continuation, locale, format, thin_mode) - response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=JP&hl=ja") - #response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=US&hl=en") + response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=JP&hl=en") if response.status_code != 200 - response = YT_POOL.client &.get("/user/#{ucid}/community?gl=JP&hl=ja") - #response = YT_POOL.client &.get("/user/#{ucid}/community?gl=US&hl=en") + response = YT_POOL.client &.get("/user/#{ucid}/community?gl=JP&hl=en") end if response.status_code != 200 @@ -33,8 +31,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode) session_token: session_token, } - response = YT_POOL.client &.post("/comment_service_ajax?action_get_comments=1&ctoken=#{continuation}&continuation=#{continuation}&hl=ja&gl=JP", headers, form: post_req) - #response = YT_POOL.client &.post("/comment_service_ajax?action_get_comments=1&ctoken=#{continuation}&continuation=#{continuation}&hl=en&gl=US", headers, form: post_req) + response = YT_POOL.client &.post("/comment_service_ajax?action_get_comments=1&ctoken=#{continuation}&continuation=#{continuation}&hl=en&gl=JP", headers, form: post_req) body = JSON.parse(response.body) body = body["response"]["continuationContents"]["itemSectionContinuation"]? || diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index dbcdf130..c866bdd9 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -89,6 +89,5 @@ def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } - #return "/browse_ajax?continuation=#{continuation}&gl=JP&hl=ja" - return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" + return "/browse_ajax?continuation=#{continuation}&gl=JP&hl=en" end diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr index 1fbcb72d..1bb8c121 100644 --- a/src/invidious/channels/videos.cr +++ b/src/invidious/channels/videos.cr @@ -85,5 +85,5 @@ end # Used in bypass_captcha_job.cr def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = "newest", v2 = false) continuation = produce_channel_videos_continuation(ucid, page, auto_generated, sort_by, v2) - return "/browse_ajax?continuation=#{continuation}&gl=JP&hl=ja" + return "/browse_ajax?continuation=#{continuation}&gl=JP&hl=en" end diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 3abffc9b..439c13f7 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -88,8 +88,7 @@ def fetch_youtube_comments(id, db, cursor, format, locale, thin_mode, region, so "cookie" => video.cookie, } - #response = YT_POOL.client(region, &.post("/comment_service_ajax?#{action}=1&hl=ja&gl=JP&pbj=1", headers, form: post_req)) - response = YT_POOL.client(region, &.post("/comment_service_ajax?#{action}=1&hl=en&gl=US&pbj=1", headers, form: post_req)) + response = YT_POOL.client(region, &.post("/comment_service_ajax?#{action}=1&hl=en&gl=JP&pbj=1", headers, form: post_req)) response = JSON.parse(response.body) # For some reason youtube puts it in an array for comment_replies but otherwise it's the same diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index d0d4902a..afe630fa 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -36,8 +36,7 @@ struct ConfigPreferences property latest_only : Bool = false property listen : Bool = false property local : Bool = false - #property locale : String = "ja-JP" - property locale : String = "en-US" + property locale : String = "ja-JP" property max_results : Int32 = 40 property notifications_only : Bool = false property player_style : String = "invidious" @@ -220,10 +219,8 @@ def login_req(f_req) "pstMsg" => "1", "checkConnection" => "youtube", "checkedDomains" => "youtube", - #"hl" => "ja", - #"deviceinfo" => %|[null,null,null,[],null,"JP",null,null,[],"GlifWebSignIn",null,[null,null,[]]]|, "hl" => "en", - "deviceinfo" => %|[null,null,null,[],null,"US",null,null,[],"GlifWebSignIn",null,[null,null,[]]]|, + "deviceinfo" => %|[null,null,null,[],null,"JP",null,null,[],"GlifWebSignIn",null,[null,null,[]]]|, "f.req" => f_req, "flowName" => "GlifWebSignIn", "flowEntry" => "ServiceLogin", diff --git a/src/invidious/helpers/signatures.cr b/src/invidious/helpers/signatures.cr index 2b5ae69a..7950ae64 100644 --- a/src/invidious/helpers/signatures.cr +++ b/src/invidious/helpers/signatures.cr @@ -12,7 +12,7 @@ struct DecryptFunction end private def fetch_decrypt_function(id = "CvFH_6DNRCY") - document = YT_POOL.client &.get("/watch?v=#{id}&gl=JP&hl=ja").body + document = YT_POOL.client &.get("/watch?v=#{id}&gl=JP&hl=en").body url = document.match(/src="(?\/s\/player\/[^\/]+\/player_ias[^\/]+\/ja_JP\/base.js)"/).not_nil!["url"] player = YT_POOL.client &.get(url).body diff --git a/src/invidious/jobs/bypass_captcha_job.cr b/src/invidious/jobs/bypass_captcha_job.cr index 2e92e3da..47e7c16b 100644 --- a/src/invidious/jobs/bypass_captcha_job.cr +++ b/src/invidious/jobs/bypass_captcha_job.cr @@ -6,7 +6,7 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJob if !random_video random_video = {id: "zj82_v2R6ts", ucid: "UCK87Lox575O_HCHBWaBSyGA"} end - {"/watch?v=#{random_video["id"]}&gl=JP&hl=ja&has_verified=1&bpctr=9999999999", produce_channel_videos_url(ucid: random_video["ucid"])}.each do |path| + {"/watch?v=#{random_video["id"]}&gl=JP&hl=en&has_verified=1&bpctr=9999999999", produce_channel_videos_url(ucid: random_video["ucid"])}.each do |path| response = YT_POOL.client &.get(path) if response.body.includes?("To continue with your YouTube experience, please fill out the form below.") html = XML.parse_html(response.body) diff --git a/src/invidious/mixes.cr b/src/invidious/mixes.cr index 7229699f..0c2a0a4a 100644 --- a/src/invidious/mixes.cr +++ b/src/invidious/mixes.cr @@ -26,7 +26,7 @@ def fetch_mix(rdid, video_id, cookies = nil, locale = nil) end video_id = "CvFH_6DNRCY" if rdid.starts_with? "OLAK5uy_" - response = YT_POOL.client &.get("/watch?v=#{video_id}&list=#{rdid}&gl=JP&hl=ja", headers) + response = YT_POOL.client &.get("/watch?v=#{video_id}&list=#{rdid}&gl=JP&hl=en", headers) initial_data = extract_initial_data(response.body) if !initial_data["contents"]["twoColumnWatchNextResults"]["playlist"]? diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr index 1a5bee03..44fa54d8 100644 --- a/src/invidious/routes/login.cr +++ b/src/invidious/routes/login.cr @@ -58,8 +58,7 @@ class Invidious::Routes::Login < Invidious::Routes::BaseRoute headers = login_page.cookies.add_request_headers(headers) lookup_req = { - #email, nil, [] of String, nil, "JP", nil, nil, 2, false, true, - email, nil, [] of String, nil, "US", nil, nil, 2, false, true, + email, nil, [] of String, nil, "JP", nil, nil, 2, false, true, {nil, nil, {2, 1, nil, 1, "https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn", diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index c978fe88..af0ce946 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -968,8 +968,7 @@ def get_video(id, db, refresh = true, region = nil, force_refresh = false) end def fetch_video(id, region) - #response = YT_POOL.client(region, &.get("/watch?v=#{id}&gl=JP&hl=ja&has_verified=1&bpctr=9999999999")) - response = YT_POOL.client(region, &.get("/watch?v=#{id}&gl=US&hl=en&has_verified=1&bpctr=9999999999")) + response = YT_POOL.client(region, &.get("/watch?v=#{id}&gl=JP&hl=en&has_verified=1&bpctr=9999999999")) if md = response.headers["location"]?.try &.match(/v=(?[a-zA-Z0-9_-]{11})/) raise VideoRedirect.new(video_id: md["id"]) @@ -984,8 +983,7 @@ def fetch_video(id, region) bypass_regions = PROXY_LIST.keys & allowed_regions if !bypass_regions.empty? region = bypass_regions[rand(bypass_regions.size)] - #response = YT_POOL.client(region, &.get("/watch?v=#{id}&gl=JP&hl=ja&has_verified=1&bpctr=9999999999")) - response = YT_POOL.client(region, &.get("/watch?v=#{id}&gl=US&hl=en&has_verified=1&bpctr=9999999999")) + response = YT_POOL.client(region, &.get("/watch?v=#{id}&gl=JP&hl=en&has_verified=1&bpctr=9999999999")) region_info = extract_polymer_config(response.body) region_info["region"] = JSON::Any.new(region) if region @@ -1000,9 +998,7 @@ def fetch_video(id, region) "video_id" => id, "eurl" => "https://youtube.googleapis.com/v/#{id}", "html5" => "1", - #"gl" => "JP", - #"hl" => "ja", - "gl" => "US", + "gl" => "JP", "hl" => "en", } if info["reason"].as_s.includes?("inappropriate")