From 78834b1548f0add25bb9bdb1de40dfa7e55fad41 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 20 Mar 2022 21:30:45 +0100 Subject: [PATCH] Fix parsing subscriptions published date --- Model/Applications/PipedAPI.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Model/Applications/PipedAPI.swift b/Model/Applications/PipedAPI.swift index 41d36024..d05520d2 100644 --- a/Model/Applications/PipedAPI.swift +++ b/Model/Applications/PipedAPI.swift @@ -309,8 +309,12 @@ final class PipedAPI: Service, ObservableObject, VideosAPI { let author = details["uploaderName"]?.stringValue ?? details["uploader"]!.stringValue let authorThumbnailURL = details["avatarUrl"]?.url ?? details["uploaderAvatar"]?.url ?? details["avatar"]?.url - let published = (details["uploadedDate"] ?? details["uploadDate"])?.stringValue ?? - (details["uploaded"]!.double! / 1000).formattedAsRelativeTime()! + let uploaded = details["uploaded"]?.doubleValue + var published = uploaded.isNil ? nil : (uploaded! / 1000).formattedAsRelativeTime() + if published.isNil { + published = (details["uploadedDate"] ?? details["uploadDate"])?.stringValue ?? "" + } + let live = details["livestream"]?.boolValue ?? (details["duration"]?.intValue == -1) return Video( @@ -318,7 +322,7 @@ final class PipedAPI: Service, ObservableObject, VideosAPI { title: details["title"]!.stringValue, author: author, length: details["duration"]!.doubleValue, - published: published, + published: published!, views: details["views"]!.intValue, description: extractDescription(from: content), channel: Channel(id: channelId, name: author, thumbnailURL: authorThumbnailURL),