Discard images that are too wide to be used as icons. Issue #1264

This commit is contained in:
Maurice Parker 2019-11-06 17:36:05 -06:00
parent 5ce45c8977
commit b0f9d97650
3 changed files with 10 additions and 4 deletions

View File

@ -9,7 +9,7 @@
import Foundation
enum ArticleExtractorConfig {
static let clientId = "{MERCURYID}"
static let clientSecret = "{MERCURYSECRET}"
static let clientId = "netnewswire"
static let clientSecret = "PM9QZZwckFPLcJdUt4BADDqwHdKCAy8zxaAakjmpGdbjEjfcAdU3CTNdBf8Lw"
static let clientURL = "https://extract.feedbin.com/parser"
}

View File

@ -20,6 +20,9 @@ extension RSHTMLMetadata {
var bestImage: RSHTMLOpenGraphImage? = nil
for image in openGraphImages {
if image.width / image.height > 2 {
continue
}
if bestImage == nil {
bestImage = image
continue
@ -51,6 +54,9 @@ extension RSHTMLMetadata {
var bestImage: RSHTMLMetadataAppleTouchIcon? = nil
for image in icons {
if image.size.width / image.size.height > 2 {
continue
}
if bestImage == nil {
bestImage = image
continue

View File

@ -182,7 +182,7 @@ private extension AppDelegate {
let homePageURLsWithNoFaviconURL = tempDir.appendingPathComponent("HomePageURLsWithNoFaviconURLCache.plist")
// If the image disk cache hasn't been flushed for 3 days and the network is available, delete it
if let flushDate = AppDefaults.lastImageCacheFlushDate, flushDate.addingTimeInterval(3600*24*3) < Date() {
// if let flushDate = AppDefaults.lastImageCacheFlushDate, flushDate.addingTimeInterval(3600*24*3) < Date() {
if let reachability = try? Reachability(hostname: "apple.com") {
if reachability.connection != .unavailable {
for tempItem in [faviconsFolderURL, imagesFolderURL, homePageToIconURL, homePagesWithNoIconURL, homePageToFaviconURL, homePageURLsWithNoFaviconURL] {
@ -196,7 +196,7 @@ private extension AppDelegate {
AppDefaults.lastImageCacheFlushDate = Date()
}
}
}
// }
try! FileManager.default.createDirectory(at: faviconsFolderURL, withIntermediateDirectories: true, attributes: nil)
let faviconsFolder = faviconsFolderURL.absoluteString