mirror of https://github.com/iv-org/invidious.git
Merge pull request #1974 from syeopite/fix1562
Fix channel info extract for video game channels
This commit is contained in:
commit
ae353cef2e
|
@ -821,6 +821,30 @@ def get_about_info(ucid, locale)
|
||||||
raise ChannelRedirect.new(channel_id: browse_endpoint["browseId"].to_s)
|
raise ChannelRedirect.new(channel_id: browse_endpoint["browseId"].to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
auto_generated = false
|
||||||
|
# Check for special auto generated gaming channels
|
||||||
|
if !initdata.has_key?("metadata")
|
||||||
|
auto_generated = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if auto_generated
|
||||||
|
author = initdata["header"]["interactiveTabbedHeaderRenderer"]["title"]["simpleText"].as_s
|
||||||
|
author_url = initdata["microformat"]["microformatDataRenderer"]["urlCanonical"].as_s
|
||||||
|
author_thumbnail = initdata["header"]["interactiveTabbedHeaderRenderer"]["boxArt"]["thumbnails"][0]["url"].as_s
|
||||||
|
|
||||||
|
# Raises a KeyError on failure.
|
||||||
|
banners = initdata["header"]["interactiveTabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
|
||||||
|
banner = banners.try &.[-1]?.try &.["url"].as_s?
|
||||||
|
|
||||||
|
description = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"]["simpleText"].as_s
|
||||||
|
description_html = HTML.escape(description).gsub("\n", "<br>")
|
||||||
|
|
||||||
|
paid = false
|
||||||
|
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
|
||||||
|
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map { |a| a.as_s }
|
||||||
|
|
||||||
|
related_channels = [] of AboutRelatedChannel
|
||||||
|
else
|
||||||
author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
|
author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
|
||||||
author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
|
author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
|
||||||
author_thumbnail = initdata["metadata"]["channelMetadataRenderer"]["avatar"]["thumbnails"][0]["url"].as_s
|
author_thumbnail = initdata["metadata"]["channelMetadataRenderer"]["avatar"]["thumbnails"][0]["url"].as_s
|
||||||
|
@ -873,11 +897,11 @@ def get_about_info(ucid, locale)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
related_channels ||= [] of AboutRelatedChannel
|
related_channels ||= [] of AboutRelatedChannel
|
||||||
|
end
|
||||||
|
|
||||||
total_views = 0_i64
|
total_views = 0_i64
|
||||||
joined = Time.unix(0)
|
joined = Time.unix(0)
|
||||||
tabs = [] of String
|
tabs = [] of String
|
||||||
auto_generated = false
|
|
||||||
|
|
||||||
tabs_json = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]?.try &.as_a?
|
tabs_json = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]?.try &.as_a?
|
||||||
if !tabs_json.nil?
|
if !tabs_json.nil?
|
||||||
|
@ -895,7 +919,7 @@ def get_about_info(ucid, locale)
|
||||||
joined = channel_about_meta["joinedDateText"]?.try &.["runs"]?.try &.as_a.reduce("") { |acc, node| acc + node["text"].as_s }
|
joined = channel_about_meta["joinedDateText"]?.try &.["runs"]?.try &.as_a.reduce("") { |acc, node| acc + node["text"].as_s }
|
||||||
.try { |text| Time.parse(text, "Joined %b %-d, %Y", Time::Location.local) } || Time.unix(0)
|
.try { |text| Time.parse(text, "Joined %b %-d, %Y", Time::Location.local) } || Time.unix(0)
|
||||||
|
|
||||||
# Auto-generated channels
|
# Normal Auto-generated channels
|
||||||
# https://support.google.com/youtube/answer/2579942
|
# https://support.google.com/youtube/answer/2579942
|
||||||
# For auto-generated channels, channel_about_meta only has ["description"]["simpleText"] and ["primaryLinks"][0]["title"]["simpleText"]
|
# For auto-generated channels, channel_about_meta only has ["description"]["simpleText"] and ["primaryLinks"][0]["title"]["simpleText"]
|
||||||
if (channel_about_meta["primaryLinks"]?.try &.size || 0) == 1 && (channel_about_meta["primaryLinks"][0]?) &&
|
if (channel_about_meta["primaryLinks"]?.try &.size || 0) == 1 && (channel_about_meta["primaryLinks"][0]?) &&
|
||||||
|
|
Loading…
Reference in New Issue