NetNewsWire/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleEntry...

113 lines
2.5 KiB
Swift
Raw Normal View History

//
// GoogleReaderCompatibleArticle.swift
// Account
//
// Created by Brent Simmons on 12/11/17.
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSParser
import RSCore
2019-06-10 22:53:35 +02:00
struct GoogleReaderCompatibleEntryWrapper: Codable {
let id: String
let updated: Int
let entries: [GoogleReaderCompatibleEntry]
enum CodingKeys: String, CodingKey {
case id = "id"
case updated = "updated"
case entries = "items"
}
}
/* {
"id": "tag:google.com,2005:reader/item/00058a3b5197197b",
"crawlTimeMsec": "1559362260113",
"timestampUsec": "1559362260113787",
"published": 1554845280,
"title": "",
"summary": {
"content": "\n<p>Found an old screenshot of NetNewsWire 1.0 for iPhone!</p>\n\n<p><img src=\"https://nnw.ranchero.com/uploads/2019/c07c0574b1.jpg\" alt=\"Netnewswire 1.0 for iPhone screenshot showing the list of feeds.\" title=\"NewsGator got renamed to Sitrion, years later, and then renamed again as Limeade.\" border=\"0\" width=\"260\" height=\"320\"></p>\n"
},
"alternate": [
{
"href": "https://nnw.ranchero.com/2019/04/09/found-an-old.html"
}
],
"categories": [
"user/-/state/com.google/reading-list",
"user/-/label/Uncategorized"
],
"origin": {
"streamId": "feed/130",
"title": "NetNewsWire"
}
}
*/
struct GoogleReaderCompatibleEntry: Codable {
2019-06-10 22:53:35 +02:00
let articleID: String
let title: String?
2019-06-10 22:53:35 +02:00
let publishedTimestamp: Double?
let crawledTimestamp: String?
let timestampUsec: String?
let summary: GoogleReaderCompatibleArticleSummary
let alternates: [GoogleReaderCompatibleAlternateLocation]
let categories: [String]
let origin: GoogleReaderCompatibleEntryOrigin
enum CodingKeys: String, CodingKey {
case articleID = "id"
case title = "title"
case summary = "summary"
2019-06-10 22:53:35 +02:00
case alternates = "alternate"
case categories = "categories"
case publishedTimestamp = "published"
case crawledTimestamp = "crawlTimeMsec"
case origin = "origin"
case timestampUsec = "timestampUsec"
}
2019-06-10 22:53:35 +02:00
func parseDatePublished() -> Date? {
2019-06-10 22:53:35 +02:00
guard let unixTime = publishedTimestamp else {
return nil
}
2019-06-10 22:53:35 +02:00
return Date(timeIntervalSince1970: unixTime)
}
}
2019-06-10 22:53:35 +02:00
struct GoogleReaderCompatibleArticleSummary: Codable {
let content: String?
enum CodingKeys: String, CodingKey {
2019-06-10 22:53:35 +02:00
case content = "content"
}
}
2019-06-10 22:53:35 +02:00
struct GoogleReaderCompatibleAlternateLocation: Codable {
let url: String?
2019-06-10 22:53:35 +02:00
enum CodingKeys: String, CodingKey {
2019-06-10 22:53:35 +02:00
case url = "href"
}
}
2019-06-10 22:53:35 +02:00
struct GoogleReaderCompatibleEntryOrigin: Codable {
let streamId: String?
let title: String?
enum CodingKeys: String, CodingKey {
case streamId = "streamId"
case title = "title"
}
}