From ae10052aaf816fe6e309dc9f92a1e6f98464a3df Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Thu, 7 Mar 2019 21:13:54 -0600 Subject: [PATCH] Fix date parsing for RSS feeds --- src/invidious.cr | 8 ++++---- src/invidious/channels.cr | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index f4f84e86a..26f98b2c1 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2072,8 +2072,8 @@ get "/feed/channel/:ucid" do |env| video_id = entry.xpath_node("videoid").not_nil!.content title = entry.xpath_node("title").not_nil!.content - published = Time.parse(entry.xpath_node("published").not_nil!.content, "%FT%X%z", Time::Location.local) - updated = Time.parse(entry.xpath_node("updated").not_nil!.content, "%FT%X%z", Time::Location.local) + published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content) + updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content) author = entry.xpath_node("author/name").not_nil!.content ucid = entry.xpath_node("channelid").not_nil!.content @@ -2361,8 +2361,8 @@ post "/feed/webhook/:token" do |env| rss = XML.parse_html(body) rss.xpath_nodes("//feed/entry").each do |entry| id = entry.xpath_node("videoid").not_nil!.content - published = Time.parse(entry.xpath_node("published").not_nil!.content, "%FT%X%z", Time::Location.local) - updated = Time.parse(entry.xpath_node("updated").not_nil!.content, "%FT%X%z", Time::Location.local) + published = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content) + updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content) video = get_video(id, PG_DB, proxies, region: nil) video = ChannelVideo.new(id, video.title, published, updated, video.ucid, video.author, video.length_seconds) diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 484aac2fa..3ecfe529e 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -112,8 +112,8 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil) rss.xpath_nodes("//feed/entry").each do |entry| video_id = entry.xpath_node("videoid").not_nil!.content title = entry.xpath_node("title").not_nil!.content - published = Time.parse(entry.xpath_node("published").not_nil!.content, "%FT%X%z", Time::Location.local) - updated = Time.parse(entry.xpath_node("updated").not_nil!.content, "%FT%X%z", Time::Location.local) + published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content) + updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content) author = entry.xpath_node("author/name").not_nil!.content ucid = entry.xpath_node("channelid").not_nil!.content