diff options
| author | Émilien (perso) <4016501+unixfox@users.noreply.github.com> | 2024-02-12 08:29:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-12 08:29:44 +0100 |
| commit | cf686202e05cfdce708a4d0d37a18a055f43a1df (patch) | |
| tree | 965f7f30ef90202af14975b658281678a18dd206 | |
| parent | c005ada48723808e507d0a4d5a3363a1c14a4f07 (diff) | |
| parent | 98c421e9f539f8d72e6842fea94d17ff0db7f38a (diff) | |
| download | invidious-cf686202e05cfdce708a4d0d37a18a055f43a1df.tar.gz invidious-cf686202e05cfdce708a4d0d37a18a055f43a1df.tar.bz2 invidious-cf686202e05cfdce708a4d0d37a18a055f43a1df.zip | |
Merge pull request #4423 from tleydxdy/xml-namespace
Fix pubsub feed parsing
| -rw-r--r-- | src/invidious/routes/feeds.cr | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr index 40bca008..e20a7139 100644 --- a/src/invidious/routes/feeds.cr +++ b/src/invidious/routes/feeds.cr @@ -407,14 +407,23 @@ module Invidious::Routes::Feeds end spawn do - rss = XML.parse_html(body) - rss.xpath_nodes("//feed/entry").each do |entry| - id = entry.xpath_node("videoid").not_nil!.content - author = entry.xpath_node("author/name").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) - - video = get_video(id, force_refresh: true) + # TODO: unify this with the other almost identical looking parts in this and channels.cr somehow? + namespaces = { + "yt" => "http://www.youtube.com/xml/schemas/2015", + "default" => "http://www.w3.org/2005/Atom", + } + rss = XML.parse(body) + rss.xpath_nodes("//default:feed/default:entry", namespaces).each do |entry| + id = entry.xpath_node("yt:videoId", namespaces).not_nil!.content + author = entry.xpath_node("default:author/default:name", namespaces).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) + + begin + video = get_video(id, force_refresh: true) + rescue + next # skip this video since it raised an exception (e.g. it is a scheduled live event) + end if CONFIG.enable_user_notifications # Deliver notifications to `/api/v1/auth/notifications` |
