Apply suggestions from code review

add videoId to resolve_url function

Co-Authored-By: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
ChunkyProgrammer
2023-08-29 19:10:01 -07:00
parent f55b96a53b
commit bb04bcc42c
5 changed files with 16 additions and 13 deletions

View File

@@ -347,9 +347,8 @@ module Invidious::Routes::API::V1::Channels
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json"
id = env.params.url["id"].to_s
ucid = env.params.query["ucid"]
ucid = env.params.query["ucid"]?
thin_mode = env.params.query["thin_mode"]?
thin_mode = thin_mode == "true"
@@ -357,6 +356,14 @@ module Invidious::Routes::API::V1::Channels
format = env.params.query["format"]?
format ||= "json"
if ucid.nil?
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
return error_json(400, "Invalid post ID") if response["error"]?
ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
else
ucid = ucid.to_s
end
begin
fetch_channel_community_post(ucid, id, locale, format, thin_mode)
rescue ex