summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-07-16 18:13:55 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-07-16 18:13:55 +0200
commit69e2eaccc017cbf0caed2f79fa789cdb0b2a2cdf (patch)
tree6b0e94b60ce6e4b21c1a9b3cda68cdde840d305a /src
parentff6166edf78b7cef685967e883c110ed5770197f (diff)
parenta38edd733002166d334261abb39a220c8972ca25 (diff)
downloadinvidious-69e2eaccc017cbf0caed2f79fa789cdb0b2a2cdf.tar.gz
invidious-69e2eaccc017cbf0caed2f79fa789cdb0b2a2cdf.tar.bz2
invidious-69e2eaccc017cbf0caed2f79fa789cdb0b2a2cdf.zip
RSS Feeds: Fix Nil assertion failed (#3958)
Diffstat (limited to 'src')
-rw-r--r--src/invidious/routes/feeds.cr26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr
index a8246b2e..40bca008 100644
--- a/src/invidious/routes/feeds.cr
+++ b/src/invidious/routes/feeds.cr
@@ -162,20 +162,26 @@ module Invidious::Routes::Feeds
return error_atom(500, ex)
end
+ namespaces = {
+ "yt" => "http://www.youtube.com/xml/schemas/2015",
+ "media" => "http://search.yahoo.com/mrss/",
+ "default" => "http://www.w3.org/2005/Atom",
+ }
+
response = YT_POOL.client &.get("/feeds/videos.xml?channel_id=#{channel.ucid}")
- rss = XML.parse_html(response.body)
+ rss = XML.parse(response.body)
- videos = rss.xpath_nodes("//feed/entry").map do |entry|
- video_id = entry.xpath_node("videoid").not_nil!.content
- title = entry.xpath_node("title").not_nil!.content
+ videos = rss.xpath_nodes("//default:feed/default:entry", namespaces).map do |entry|
+ video_id = entry.xpath_node("yt:videoId", namespaces).not_nil!.content
+ title = entry.xpath_node("default:title", namespaces).not_nil!.content
- published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content)
- updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content)
+ published = Time.parse_rfc3339(entry.xpath_node("default:published", namespaces).not_nil!.content)
+ updated = Time.parse_rfc3339(entry.xpath_node("default:updated", namespaces).not_nil!.content)
- author = entry.xpath_node("author/name").not_nil!.content
- ucid = entry.xpath_node("channelid").not_nil!.content
- description_html = entry.xpath_node("group/description").not_nil!.to_s
- views = entry.xpath_node("group/community/statistics").not_nil!.["views"].to_i64
+ author = entry.xpath_node("default:author/default:name", namespaces).not_nil!.content
+ ucid = entry.xpath_node("yt:channelId", namespaces).not_nil!.content
+ description_html = entry.xpath_node("media:group/media:description", namespaces).not_nil!.to_s
+ views = entry.xpath_node("media:group/media:community/media:statistics", namespaces).not_nil!.["views"].to_i64
SearchVideo.new({
title: title,