From 33b07566cbc07295131e9fe0e14643fbd9c5d14a Mon Sep 17 00:00:00 2001 From: Shav Kinderlehrer Date: Thu, 22 Feb 2024 14:13:53 -0500 Subject: Revamp EpisodeIconView + format item.overview properly Some metadata sources use '
' instead of '\n' for newlines. This fixes that for the most part. --- Jel/Extensions/BaseItemDtoExtensions.swift | 36 ++++++++++++++++++++++++++++++ Jel/Extensions/JellyfinKitExtensions.swift | 28 ----------------------- 2 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 Jel/Extensions/BaseItemDtoExtensions.swift delete mode 100644 Jel/Extensions/JellyfinKitExtensions.swift (limited to 'Jel/Extensions') 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: "
", with: "\n") + } + } +} diff --git a/Jel/Extensions/JellyfinKitExtensions.swift b/Jel/Extensions/JellyfinKitExtensions.swift deleted file mode 100644 index 197731c..0000000 --- a/Jel/Extensions/JellyfinKitExtensions.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// 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 - } -} -- cgit v1.2.3