Parse story image and tags

This commit is contained in:
Anh Do 2020-03-14 18:19:50 -04:00
parent 1d3073c593
commit 0479bbd9f5
No known key found for this signature in database
GPG Key ID: 451E3092F917B62D
2 changed files with 8 additions and 1 deletions

View File

@ -22,11 +22,16 @@ struct NewsBlurStoriesResponse: Decodable {
let url: String?
let authorName: String?
let contentHTML: String?
var imageURL: String? {
return imageURLs?.first
}
var tags: [String]?
var datePublished: Date? {
let interval = (publishedTimestamp as NSString).doubleValue
return Date(timeIntervalSince1970: interval)
}
private var imageURLs: [String]?
private var publishedTimestamp: String
}
}
@ -45,6 +50,8 @@ extension NewsBlurStoriesResponse.Story {
case url = "story_permalink"
case authorName = "story_authors"
case contentHTML = "story_content"
case imageURLs = "image_urls"
case tags = "story_tags"
case publishedTimestamp = "story_timestamp"
}
}

View File

@ -261,7 +261,7 @@ extension NewsBlurAccountDelegate {
let parsedItems: [ParsedItem] = stories.map { story in
let author = Set([ParsedAuthor(name: story.authorName, url: nil, avatarURL: nil, emailAddress: nil)])
return ParsedItem(syncServiceID: story.storyID, uniqueID: String(story.storyID), feedURL: String(story.feedID), url: story.url, externalURL: nil, title: story.title, contentHTML: story.contentHTML, contentText: nil, summary: nil, imageURL: nil, bannerImageURL: nil, datePublished: story.datePublished, dateModified: nil, authors: author, tags: nil, attachments: nil)
return ParsedItem(syncServiceID: story.storyID, uniqueID: String(story.storyID), feedURL: String(story.feedID), url: story.url, externalURL: nil, title: story.title, contentHTML: story.contentHTML, contentText: nil, summary: nil, imageURL: story.imageURL, bannerImageURL: nil, datePublished: story.datePublished, dateModified: nil, authors: author, tags: Set(story.tags ?? []), attachments: nil)
}
return Set(parsedItems)