mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 22:39:31 -05:00
Merge pull request #1506 from tirz/fix-channel_parsing
fix: channel info parsing
This commit is contained in:
commit
4acfd2c342
@ -801,11 +801,11 @@ def get_about_info(ucid, locale)
|
|||||||
raise InfoException.new(error_message)
|
raise InfoException.new(error_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
author = about.xpath_node(%q(//meta[@name="title"])).not_nil!["content"]
|
author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
|
||||||
author_url = about.xpath_node(%q(//link[@rel="canonical"])).not_nil!["href"]
|
author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
|
||||||
author_thumbnail = about.xpath_node(%q(//link[@rel="image_src"])).not_nil!["href"]
|
author_thumbnail = initdata["metadata"]["channelMetadataRenderer"]["avatar"]["thumbnails"][0]["url"].as_s
|
||||||
|
|
||||||
ucid = about.xpath_node(%q(//meta[@itemprop="channelId"])).not_nil!["content"]
|
ucid = initdata["metadata"]["channelMetadataRenderer"]["externalId"].as_s
|
||||||
|
|
||||||
# Raises a KeyError on failure.
|
# Raises a KeyError on failure.
|
||||||
banners = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
|
banners = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
|
||||||
|
@ -598,7 +598,7 @@ def create_notification_stream(env, topics, connection_channel)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_initial_data(body) : Hash(String, JSON::Any)
|
def extract_initial_data(body) : Hash(String, JSON::Any)
|
||||||
return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(JSON\.parse\(")?(?<info>\{.*?\})("\))?;/m).try &.["info"] || "{}").as_h
|
return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(?<info>\{.*?\});/mx).try &.["info"] || "{}").as_h
|
||||||
end
|
end
|
||||||
|
|
||||||
def proxy_file(response, env)
|
def proxy_file(response, env)
|
||||||
|
Loading…
Reference in New Issue
Block a user