Always craft Community Post params

This commit is contained in:
ChunkyProgrammer 2023-08-07 12:46:19 -07:00
parent 734f1b7764
commit f55b96a53b
2 changed files with 16 additions and 19 deletions

View File

@ -24,23 +24,21 @@ def fetch_channel_community(ucid, cursor, locale, format, thin_mode)
return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode) return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode)
end end
def fetch_channel_community_post(ucid, post_id, locale, format, thin_mode, params : String | Nil = nil) def fetch_channel_community_post(ucid, post_id, locale, format, thin_mode)
if params.nil? object = {
object = { "2:string" => "community",
"2:string" => "community", "25:embedded" => {
"25:embedded" => { "22:string" => post_id.to_s,
"22:string" => post_id.to_s, },
}, "45:embedded" => {
"45:embedded" => { "2:varint" => 1_i64,
"2:varint" => 1_i64, "3:varint" => 1_i64,
"3:varint" => 1_i64, },
}, }
} params = object.try { |i| Protodec::Any.cast_json(i) }
params = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) }
.try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) }
.try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) }
.try { |i| URI.encode_www_form(i) }
end
initial_data = YoutubeAPI.browse(ucid, params: params) initial_data = YoutubeAPI.browse(ucid, params: params)

View File

@ -216,8 +216,7 @@ module Invidious::Routes::Channels
return error_template(400, "Invalid post ID") if response["error"]? return error_template(400, "Invalid post ID") if response["error"]?
ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
params = response.dig("endpoint", "browseEndpoint", "params").as_s post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode)
post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode, params: params)
end end
post_response = JSON.parse(post_response) post_response = JSON.parse(post_response)