Account for The Older Reader's different use of item id's
This commit is contained in:
parent
f7771fc509
commit
071af20304
@ -1036,7 +1036,23 @@ private extension ReaderAPIAccountDelegate {
|
||||
// let authors = Set([ParsedAuthor(name: entry.authorName, url: entry.jsonFeed?.jsonFeedAuthor?.url, avatarURL: entry.jsonFeed?.jsonFeedAuthor?.avatarURL, emailAddress: nil)])
|
||||
// let feed = account.idToFeedDictionary[entry.origin.streamId!]! // TODO clean this up
|
||||
|
||||
return ParsedItem(syncServiceID: entry.uniqueID(), uniqueID: entry.uniqueID(), feedURL: streamID, url: nil, externalURL: entry.alternates.first?.url, title: entry.title, language: nil, contentHTML: entry.summary.content, contentText: nil, summary: entry.summary.content, imageURL: nil, bannerImageURL: nil, datePublished: entry.parseDatePublished(), dateModified: nil, authors: nil, tags: nil, attachments: nil)
|
||||
return ParsedItem(syncServiceID: entry.uniqueID(variant: variant),
|
||||
uniqueID: entry.uniqueID(variant: variant),
|
||||
feedURL: streamID,
|
||||
url: nil,
|
||||
externalURL: entry.alternates.first?.url,
|
||||
title: entry.title,
|
||||
language: nil,
|
||||
contentHTML: entry.summary.content,
|
||||
contentText: nil,
|
||||
summary: entry.summary.content,
|
||||
imageURL: nil,
|
||||
bannerImageURL: nil,
|
||||
datePublished: entry.parseDatePublished(),
|
||||
dateModified: nil,
|
||||
authors: nil,
|
||||
tags: nil,
|
||||
attachments: nil)
|
||||
}
|
||||
|
||||
return Set(parsedItems)
|
||||
|
@ -639,9 +639,13 @@ final class ReaderAPICaller: NSObject {
|
||||
}
|
||||
|
||||
let itemIds = itemRefs.map { (reference) -> String in
|
||||
// Convert the IDs to the (stupid) Google Hex Format
|
||||
let idValue = Int(reference.itemId)!
|
||||
return String(idValue, radix: 16, uppercase: false)
|
||||
if self.variant == .theOldReader {
|
||||
return reference.itemId
|
||||
} else {
|
||||
// Convert the IDs to the (stupid) Google Hex Format
|
||||
let idValue = Int(reference.itemId)!
|
||||
return String(idValue, radix: 16, uppercase: false)
|
||||
}
|
||||
}
|
||||
|
||||
self.retrieveEntries(articleIDs: itemIds) { (results) in
|
||||
|
@ -74,15 +74,13 @@ struct ReaderAPIEntry: Codable {
|
||||
}
|
||||
|
||||
func parseDatePublished() -> Date? {
|
||||
|
||||
guard let unixTime = publishedTimestamp else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Date(timeIntervalSince1970: unixTime)
|
||||
}
|
||||
|
||||
func uniqueID() -> String {
|
||||
func uniqueID(variant: ReaderAPIVariant) -> String {
|
||||
// Should look something like "tag:google.com,2005:reader/item/00058b10ce338909"
|
||||
// REGEX feels heavy, I should be able to just split on / and take the last element
|
||||
|
||||
@ -90,6 +88,10 @@ struct ReaderAPIEntry: Codable {
|
||||
return articleID
|
||||
}
|
||||
|
||||
guard variant != .theOldReader else {
|
||||
return idPart
|
||||
}
|
||||
|
||||
// Convert hex representation back to integer and then a string representation
|
||||
guard let idNumber = Int(idPart, radix: 16) else {
|
||||
return articleID
|
||||
@ -97,6 +99,7 @@ struct ReaderAPIEntry: Codable {
|
||||
|
||||
return String(idNumber, radix: 10, uppercase: false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ReaderAPIArticleSummary: Codable {
|
||||
@ -115,7 +118,6 @@ struct ReaderAPIAlternateLocation: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct ReaderAPIEntryOrigin: Codable {
|
||||
let streamId: String?
|
||||
let title: String?
|
||||
@ -125,4 +127,3 @@ struct ReaderAPIEntryOrigin: Codable {
|
||||
case title = "title"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user