diff options
author | Shav Kinderlehrer <[email protected]> | 2024-02-22 14:13:53 -0500 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-02-22 14:13:53 -0500 |
commit | 33b07566cbc07295131e9fe0e14643fbd9c5d14a (patch) | |
tree | cfdcf1ea68a9965f6301979bb7de5a3d18f29650 /Jel/Extensions/BaseItemDtoExtensions.swift | |
parent | 1ce620567c64c92872261317863695c4660acbd0 (diff) | |
download | jel-33b07566cbc07295131e9fe0e14643fbd9c5d14a.tar.gz jel-33b07566cbc07295131e9fe0e14643fbd9c5d14a.zip |
Revamp EpisodeIconView + format item.overview properly
Some metadata sources use '<br>' instead of '\n' for newlines.
This fixes that for the most part.
Diffstat (limited to 'Jel/Extensions/BaseItemDtoExtensions.swift')
-rw-r--r-- | Jel/Extensions/BaseItemDtoExtensions.swift | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Jel/Extensions/BaseItemDtoExtensions.swift b/Jel/Extensions/BaseItemDtoExtensions.swift new file mode 100644 index 0000000..27771bb --- /dev/null +++ b/Jel/Extensions/BaseItemDtoExtensions.swift @@ -0,0 +1,36 @@ +// +// JellyfinKitExtensions.swift +// Jel +// +// Created by zerocool on 12/24/23. +// + +import Foundation +import JellyfinKit + +extension BaseItemDto { + func getRuntime() -> String? { + let formatter: DateComponentsFormatter = { + let localFormatter = DateComponentsFormatter() + localFormatter.unitsStyle = .brief + localFormatter.allowedUnits = [.hour, .minute] + + return localFormatter + }() + + if let runTimeTicks = self.runTimeTicks { + let text = formatter.string(from: Double(runTimeTicks / 10_000_000)) + return text + } + + return nil + } +} + +extension BaseItemDto { + var overviewNL: String? { + get { + self.overview?.replacingOccurrences(of: "<br>", with: "\n") + } + } +} |