package jsonfeed

  1. Overview
  2. Docs

Module Jsonfeed.AttachmentSource

Attachments for JSON Feed items.

An attachment represents an external resource related to a feed item, such as audio files for podcasts, video files, or other downloadable content. Attachments with identical titles indicate alternate formats of the same resource.

Sourcetype t

The type representing an attachment.

Unknown Fields

Sourcemodule Unknown : sig ... end

Jsont Type

Sourceval jsont : t Jsont.t

Declarative JSON type for attachments.

Maps JSON objects with "url" (required), "mime_type" (required), and optional "title", "size_in_bytes", "duration_in_seconds" fields.

Construction

Sourceval create : url:string -> mime_type:string -> ?title:string -> ?size_in_bytes:int64 -> ?duration_in_seconds:int -> ?unknown:Unknown.t -> unit -> t

create ~url ~mime_type ?title ?size_in_bytes ?duration_in_seconds ?unknown () creates an attachment object.

  • parameter url

    The location of the attachment (required)

  • parameter mime_type

    The MIME type of the attachment, e.g. "audio/mpeg" (required)

  • parameter title

    The name of the attachment; identical titles indicate alternate formats of the same resource

  • parameter size_in_bytes

    The size of the attachment file in bytes

  • parameter duration_in_seconds

    The duration of the attachment in seconds (for audio/video)

  • parameter unknown

    Unknown/custom fields for extensions (default: empty)

Examples:

  (* Simple attachment *)
  let att =
    Attachment.create ~url:"https://example.com/episode.mp3"
      ~mime_type:"audio/mpeg" ()

  (* Podcast episode with metadata *)
  let att =
    Attachment.create ~url:"https://example.com/episode.mp3"
      ~mime_type:"audio/mpeg" ~title:"Episode 42" ~size_in_bytes:15_728_640L
      ~duration_in_seconds:1800 ()

Accessors

Sourceval url : t -> string

url t returns the attachment's URL.

Sourceval mime_type : t -> string

mime_type t returns the attachment's MIME type.

Sourceval title : t -> string option

title t returns the attachment's title, if set.

Sourceval size_in_bytes : t -> int64 option

size_in_bytes t returns the attachment's size in bytes, if set.

Sourceval duration_in_seconds : t -> int option

duration_in_seconds t returns the attachment's duration, if set.

Sourceval unknown : t -> Unknown.t

unknown t returns unrecognized fields from the JSON.

Comparison

Sourceval equal : t -> t -> bool

equal a b tests equality between two attachments.

Pretty Printing

Sourceval pp : Format.formatter -> t -> unit

pp ppf t pretty prints an attachment to the formatter.

The output is human-readable and suitable for debugging.

Example output:

episode.mp3 (audio/mpeg, 15.0 MB, 30m0s)