Change date parsing from Invidious

This commit is contained in:
Arkadiusz Fal 2022-12-13 21:55:03 +01:00
parent 2a7c51abda
commit 4fc2f964b2
2 changed files with 6 additions and 2 deletions

View File

@ -19,7 +19,9 @@ extension Double {
let date = Date(timeIntervalSince1970: self)
let formatter = RelativeDateTimeFormatter()
formatter.unitsStyle = .full
formatter.dateTimeStyle = .named
formatter.unitsStyle = .short
formatter.formattingContext = .standalone
return formatter.localizedString(for: date, relativeTo: Date())
}

View File

@ -460,10 +460,12 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
func extractVideo(from json: JSON) -> Video {
let indexID: String?
var id: Video.ID
var published = json["publishedText"].stringValue
var publishedAt: Date?
if let publishedInterval = json["published"].double {
publishedAt = Date(timeIntervalSince1970: publishedInterval)
published = ""
}
let videoID = json["videoId"].stringValue
@ -486,7 +488,7 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
title: json["title"].stringValue,
author: json["author"].stringValue,
length: json["lengthSeconds"].doubleValue,
published: json["publishedText"].stringValue,
published: published,
views: json["viewCount"].intValue,
description: description,
genre: json["genre"].stringValue,