Add chapter data type (#6)

This commit is contained in:
Daniel J. Summers 2023-07-31 22:17:14 -04:00
parent 79c304493c
commit b84a0f711f
3 changed files with 42 additions and 0 deletions

View File

@ -318,6 +318,8 @@ type SQLiteData (conn : SqliteConnection, log : ILogger<SQLiteData>, ser : JsonS
Subtitle = Map.tryString "subtitle" epRdr
Explicit = Map.tryString "explicit" epRdr
|> Option.map ExplicitRating.parse
Chapters = Map.tryString "chapters" epRdr
|> Option.map (Utils.deserialize<Chapter list> ser)
ChapterFile = Map.tryString "chapter_file" epRdr
ChapterType = Map.tryString "chapter_type" epRdr
TranscriptUrl = Map.tryString "transcript_url" epRdr

View File

@ -161,6 +161,41 @@ module ExplicitRating =
| x -> raise (invalidArg "rating" $"{x} is not a valid explicit rating")
/// A location (specified by Podcast Index)
type Location =
{ /// The name of the location (free-form text)
Name : string
/// A geographic coordinate string (RFC 5870)
Geo : string option
/// An OpenStreetMap query
Osm : string option
}
/// A chapter in a podcast episode
type Chapter =
{ /// The start time for the chapter
StartTime : Duration
/// The title for this chapter
Title : string option
/// A URL for an image for this chapter
ImageUrl : string option
/// Whether this chapter is hidden
IsHidden : bool option
/// The episode end time for the chapter
EndTime : Duration option
/// A location that applies to a chapter
Location : Location option
}
open NodaTime.Text
/// A podcast episode
@ -186,6 +221,9 @@ type Episode =
/// This episode's explicit rating (overrides podcast rating if present)
Explicit : ExplicitRating option
/// Chapters for this episode
Chapters : Chapter list option
/// A link to a chapter file
ChapterFile : string option
@ -229,6 +267,7 @@ module Episode =
ImageUrl = None
Subtitle = None
Explicit = None
Chapters = None
ChapterFile = None
ChapterType = None
TranscriptUrl = None

View File

@ -788,6 +788,7 @@ type EditPostModel =
ImageUrl = noneIfBlank this.ImageUrl
Subtitle = noneIfBlank this.Subtitle
Explicit = noneIfBlank this.Explicit |> Option.map ExplicitRating.parse
Chapters = match post.Episode with Some e -> e.Chapters | None -> None
ChapterFile = noneIfBlank this.ChapterFile
ChapterType = noneIfBlank this.ChapterType
TranscriptUrl = noneIfBlank this.TranscriptUrl