Skip to content

Attachments ‐ Improving Multimedia Support

Arturs Krumins edited this page Nov 2, 2023 · 1 revision

Motivation

While the primary focus of NNW is certainly written articles, a lot of content has moved to (and might only be available in) other mediums like audio and video.
And most of the benefits of using RSS applies to these other mediums too like:

  • Users being in control of their feeds
  • Offline consumption
  • No distracting recommendation algorithms, designed to maximise watch/listen time instead of quality information.

Considerations

  • Since NNW is an open source project it's important new features are implemented in a way, that does not increase the amount of support required.
  • The implementation should not require themes to be updated, since there might be many users using unofficial or modified themes.

Implementation

The feature could be implemented in 3 distinct steps:

1. Database

The good news is that RSParser already has RSParser.ParsedAttachment which is parsed from most feed types. The proposal is to add a Set<Attachment> to the Articles.Article struct. Basically a type-safe version of what's outlined in jsonfeed:

struct Attachment {
    let url: URL
    let type: UTType
    let title: String?
    let sizeInBytes: UInt?
    let durationInSeconds: UInt?
}

The attachments would be stored in the database similarly to how Articles.Author is already handled with many-to-many relationship and uniquely identified by the url:

extension Attachment: Identifiable {
   var id: URL { url }
}

2. UI

Download Button + QuickLook

download-button.mp4

The simplest solution would be to add a button that downloads the attachments (showing progress), and then presents all attachments in QLPreviewController allowing user to view and store the attachments.
This solution would also serve as a fallback for older versions of OS

The files could be downloaded to temporaryDirectory/hashOfTheFile/url.lastPathComponent For quicklook to work correctly, the URL requires a corresponding file extension.

Integrated

attachments

More involved approach could be to show the attachments above the article, including:

  • Title (fallback to last path component of the url)
  • Download button for each file
  • Optional preview for images, audio and video

3. Related Issues

There are few additional issues that would improve media support and UX: