Dynamically maps outdated artwork URLs to correct URLs

This commit is contained in:
Riley Testut 2021-11-16 16:31:58 -08:00
parent 08e870c94c
commit 11041ef1e9

View File

@ -45,12 +45,16 @@ public class Game: _Game, GameProtocol
// 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)
else if let host = unwrappedArtworkURL.host?.lowercased(), host == "img.gamefaqs.net" || host == "gamefaqs1.cbsistatic.com",
var components = URLComponents(url: unwrappedArtworkURL, resolvingAgainstBaseURL: false)
{
// Quick fix for broken album artwork URLs due to host change.
components.host = "gamefaqs1.cbsistatic.com"
components.host = "gamefaqs.gamespot.com"
components.scheme = "https"
let updatedPath = "/a" + components.path
components.path = updatedPath
if let url = components.url
{
artworkURL = url