summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com>2020-11-30 19:16:31 +0000
committerGitHub <noreply@github.com>2020-11-30 19:16:31 +0000
commit4acfd2c3423181f65fe53c4b56ddd021eb3e55dd (patch)
tree003d1bf70022cb19d6d060c5556466f236b18ad8
parent78ae9ff093f5305978b40c03bc15392faff1faa2 (diff)
parentdf3f9a2ae88310474d0e6be4886d3e78eaf0d28d (diff)
downloadinvidious-4acfd2c3423181f65fe53c4b56ddd021eb3e55dd.tar.gz
invidious-4acfd2c3423181f65fe53c4b56ddd021eb3e55dd.tar.bz2
invidious-4acfd2c3423181f65fe53c4b56ddd021eb3e55dd.zip
Merge pull request #1506 from tirz/fix-channel_parsing
fix: channel info parsing
-rw-r--r--src/invidious/channels.cr8
-rw-r--r--src/invidious/helpers/helpers.cr2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr
index 82921ac7..93507c56 100644
--- a/src/invidious/channels.cr
+++ b/src/invidious/channels.cr
@@ -801,11 +801,11 @@ def get_about_info(ucid, locale)
raise InfoException.new(error_message)
end
- author = about.xpath_node(%q(//meta[@name="title"])).not_nil!["content"]
- author_url = about.xpath_node(%q(//link[@rel="canonical"])).not_nil!["href"]
- author_thumbnail = about.xpath_node(%q(//link[@rel="image_src"])).not_nil!["href"]
+ author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
+ author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
+ 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.
banners = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 7a0cb3d3..dc68fb5c 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -598,7 +598,7 @@ def create_notification_stream(env, topics, connection_channel)
end
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
def proxy_file(response, env)