Version 2.1 #41
@ -163,17 +163,24 @@ let private addEpisode (webLog: WebLog) (podcast: PodcastOptions) (episode: Epis
|
|||||||
episode.Subtitle |> Option.iter (fun it -> item.ElementExtensions.Add("subtitle", Namespace.iTunes, it))
|
episode.Subtitle |> Option.iter (fun it -> item.ElementExtensions.Add("subtitle", Namespace.iTunes, it))
|
||||||
episode.FormatDuration() |> Option.iter (fun it -> item.ElementExtensions.Add("duration", Namespace.iTunes, it))
|
episode.FormatDuration() |> Option.iter (fun it -> item.ElementExtensions.Add("duration", Namespace.iTunes, it))
|
||||||
|
|
||||||
match episode.ChapterFile with
|
let chapterUrl, chapterMimeType =
|
||||||
| Some chapters ->
|
match episode.Chapters, episode.ChapterFile with
|
||||||
let url = toAbsolute webLog chapters
|
| Some _, _ ->
|
||||||
|
Some $"{webLog.AbsoluteUrl post.Permalink}?chapters", Some JSON_CHAPTERS
|
||||||
|
| None, Some chapters ->
|
||||||
let typ =
|
let typ =
|
||||||
match episode.ChapterType with
|
match episode.ChapterType with
|
||||||
| Some mime -> Some mime
|
| Some mime -> Some mime
|
||||||
| None when chapters.EndsWith ".json" -> Some "application/json+chapters"
|
| None when chapters.EndsWith ".json" -> Some JSON_CHAPTERS
|
||||||
| None -> None
|
| None -> None
|
||||||
|
Some (toAbsolute webLog chapters), typ
|
||||||
|
| None, None -> None, None
|
||||||
|
|
||||||
|
match chapterUrl with
|
||||||
|
| Some url ->
|
||||||
let elt = xmlDoc.CreateElement("podcast", "chapters", Namespace.podcast)
|
let elt = xmlDoc.CreateElement("podcast", "chapters", Namespace.podcast)
|
||||||
elt.SetAttribute("url", url)
|
elt.SetAttribute("url", url)
|
||||||
typ |> Option.iter (fun it -> elt.SetAttribute("type", it))
|
chapterMimeType |> Option.iter (fun it -> elt.SetAttribute("type", it))
|
||||||
item.ElementExtensions.Add elt
|
item.ElementExtensions.Add elt
|
||||||
| None -> ()
|
| None -> ()
|
||||||
|
|
||||||
|
@ -268,6 +268,9 @@ let redirectToGet url : HttpHandler = fun _ ctx -> task {
|
|||||||
return! redirectTo false (ctx.WebLog.RelativeUrl(Permalink url)) earlyReturn ctx
|
return! redirectTo false (ctx.WebLog.RelativeUrl(Permalink url)) earlyReturn ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The MIME type for podcast episode JSON chapters
|
||||||
|
let JSON_CHAPTERS = "application/json+chapters"
|
||||||
|
|
||||||
|
|
||||||
/// Handlers for error conditions
|
/// Handlers for error conditions
|
||||||
module Error =
|
module Error =
|
||||||
|
@ -238,7 +238,7 @@ let chapters (post: Post) : HttpHandler = fun next ctx ->
|
|||||||
jsonFile["fileName"] <- absoluteUrl ep.Media ctx
|
jsonFile["fileName"] <- absoluteUrl ep.Media ctx
|
||||||
if defaultArg ep.ChapterWaypoints false then jsonFile["waypoints"] <- true
|
if defaultArg ep.ChapterWaypoints false then jsonFile["waypoints"] <- true
|
||||||
jsonFile["chapters"] <- chapterData
|
jsonFile["chapters"] <- chapterData
|
||||||
json jsonFile next ctx
|
(setContentType JSON_CHAPTERS >=> json jsonFile) next ctx
|
||||||
| None ->
|
| None ->
|
||||||
match ep.ChapterFile with
|
match ep.ChapterFile with
|
||||||
| Some file -> redirectTo true file next ctx
|
| Some file -> redirectTo true file next ctx
|
||||||
|
Loading…
Reference in New Issue
Block a user