VocalPodcastProject / vocal

A powerful, beautiful, and simple podcast client for the modern free desktop.
GNU General Public License v3.0
346 stars 49 forks source link

Support multiple datetime formats for episode pubdate #468

Closed jonafato closed 2 years ago

jonafato commented 3 years ago

The RSS spec states that pubdates should be formatted according to RFC 822, but podcast feeds don't always conform to that (see episode three of Conversations in Code for an example). Currently, if Vocal encounters a pubdate of any other format, it crashes. To prevent that, this change does two things:

  1. Adds support for parsing multiple datetime formats. Only two formats are supported initially. A more robust implementation would include many common formats seen across podcast feeds.

  2. Sets the default pubdate to the current time. This is not an ideal solution, but it prevents the application from crashing.

jonafato commented 3 years ago

@nathandyer This PR is a sort of starting point for a long-term solution here. The supported time formats list should be fleshed out more, and this logic most likely belongs in a util module. That said, it prevents some crashes, so I wanted to get the change up here ASAP to get the application into a more stable state.

jonafato commented 3 years ago

Adding a copy of the problematic feed that caused this issue, since it's been fixed upstream:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>Conversations in Code</title>
    <link>https://conversationsincode.xyz</link>
    <language>en-us</language>
    <copyright>© 2020 conversationsincode.xyz</copyright>
    <itunes:subtitle>An ongoing discussion between two mates on geeky tools, pursuits and goals</itunes:subtitle>
    <itunes:author>Mike Williams and Campbell Barton</itunes:author>
    <itunes:summary>A developer and a geek tinkerer talk about software tools, some hardware, Linux/FOSS, projects we're working on, etc.</itunes:summary>
    <description>A developer and a geek tinkerer talk about software tools, some hardware, Linux/FOSS, projects we're working on, etc.</description>
    <itunes:explicit>no</itunes:explicit>
    <itunes:owner>
      <itunes:name>conversationsincode.xyz</itunes:name>
      <itunes:email>conversationsincode@gmail.com</itunes:email>
    </itunes:owner>
    <itunes:image href="https://conversationsincode.xyz/rss/podcast_logo_header.png" />
    <itunes:category text="Technology">
    </itunes:category>
    <itunes:category text="Technology"/>
    <item>
      <title>Episode 1: Configuration and Customization</title>
      <pubDate>Sun, 16 Aug 2020 09:00:00 GMT</pubDate>
      <itunes:episodeType>full</itunes:episodeType>
      <itunes:author>Mike Williams and Campbell Barton</itunes:author>
      <itunes:subtitle>Configuration and Customization</itunes:subtitle>
      <itunes:summary>We introduce the new show and discuss the topic of configuration, customization good defaults.</itunes:summary>
      <enclosure url="https://conversationsincode.xyz/episodes/cic_001_config_and_customizing.mp3" length="61046912" type="audio/mpeg" />
      <guid>https://conversationsincode.xyz/episodes/cic_001_config_and_customizing.mp3</guid>
      <itunes:duration>1:24:47</itunes:duration>
      <itunes:explicit>no</itunes:explicit>
      <description>We introduce the new show and discuss the topic of configuration.</description>
      <itunes:keywords>configuration, git, emacs</itunes:keywords>
    </item>
    <item>
      <title>Episode 2: Shell Scripting and Command Line Interfaces</title>
      <pubDate>Sun, 30 Aug 2020 09:00:00 GMT</pubDate>
      <itunes:episodeType>full</itunes:episodeType>
      <itunes:author>Mike Williams and Campbell Barton</itunes:author>
      <itunes:subtitle>Shell Scripting and Command Line Interfaces</itunes:subtitle>
      <itunes:summary>We discuss shell scripting, next generation shells and command line interfaces.</itunes:summary>
      <enclosure url="https://conversationsincode.xyz/episodes/cic_002_terminal_and_shells.mp3" length="32059520" type="audio/mpeg" />
      <guid>https://conversationsincode.xyz/episodes/cic_002_terminal_and_shells.mp3</guid>
      <itunes:duration>44:31</itunes:duration>
      <itunes:explicit>no</itunes:explicit>
      <description>We discuss shell scripting, next generation shells and command line interfaces.</description>
      <itunes:keywords>command line, bash, zsh, shell, terminal</itunes:keywords>
    </item>
    <item>
      <title>Episode 3: Introduction to Plain Text Accounting</title>
      <pubDate>Wed, Sep 16 2020 09:00:00 GMT</pubDate>
      <itunes:episodeType>full</itunes:episodeType>
      <itunes:author>Mike Williams and Campbell Barton</itunes:author>
      <itunes:subtitle>Introduction to Plain Text Accounting</itunes:subtitle>
      <itunes:summary>We discuss our experience using plain text accounting, compared to other solutions and talk about the pros and cons.</itunes:summary>
      <enclosure url="https://conversationsincode.xyz/episodes/cic_003_plain_text_accounting.mp3" length="44695680" type="audio/mpeg" />
      <guid>https://conversationsincode.xyz/episodes/cic_003_plain_text_accounting.mp3</guid>
      <itunes:duration>1:02:05</itunes:duration>
      <itunes:explicit>no</itunes:explicit>
      <description>We discuss our experience using plain text accounting, compared to other solutions and talk about the pros and cons.</description>
      <itunes:keywords>accounting, ledger, hledger</itunes:keywords>
    </item>
  </channel>
</rss>
nathandyer commented 2 years ago

@jonafato Since this PR fixes some significant crashes, I agree, let's go ahead and merge. Please feel free to open an issue later on and we can address this in more depth if needed. Thank you!