Dynamically maps old album artwork URLs to new ones
This commit is contained in:
parent
763e410ce9
commit
a0f60de926
@ -30,10 +30,24 @@ public class Game: _Game, GameProtocol
|
|||||||
var artworkURL = self.primitiveValue(forKey: #keyPath(Game.artworkURL)) as? URL
|
var artworkURL = self.primitiveValue(forKey: #keyPath(Game.artworkURL)) as? URL
|
||||||
self.didAccessValue(forKey: #keyPath(Game.artworkURL))
|
self.didAccessValue(forKey: #keyPath(Game.artworkURL))
|
||||||
|
|
||||||
if let unwrappedArtworkURL = artworkURL, unwrappedArtworkURL.isFileURL
|
if let unwrappedArtworkURL = artworkURL
|
||||||
{
|
{
|
||||||
// Recreate the stored URL relative to current sandbox location.
|
if unwrappedArtworkURL.isFileURL
|
||||||
artworkURL = URL(fileURLWithPath: unwrappedArtworkURL.relativePath, relativeTo: DatabaseManager.gamesDirectoryURL)
|
{
|
||||||
|
// Recreate the stored URL relative to current sandbox location.
|
||||||
|
artworkURL = URL(fileURLWithPath: unwrappedArtworkURL.relativePath, relativeTo: DatabaseManager.gamesDirectoryURL)
|
||||||
|
}
|
||||||
|
else if unwrappedArtworkURL.host?.lowercased() == "img.gamefaqs.net", var components = URLComponents(url: unwrappedArtworkURL, resolvingAgainstBaseURL: false)
|
||||||
|
{
|
||||||
|
// Quick fix for broken album artwork URLs due to host change.
|
||||||
|
components.host = "gamefaqs1.cbsistatic.com"
|
||||||
|
components.scheme = "https"
|
||||||
|
|
||||||
|
if let url = components.url
|
||||||
|
{
|
||||||
|
artworkURL = url
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return artworkURL
|
return artworkURL
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user