In this thread it has been stated that getting artist artwork through the MusicKit api isn't allowed because of copyright issues. My question is:
Is using the Apple Music REST api to get album artwork via the OpenGraph API also disallowed such that my app would be rejected? Wonder if I should pursue this option that I found or if I need to find another way? Seems like the answer would be no, but wanted to double check.
Thanks for your response, this is my first app that I'm trying to publish to the store and I'd like to avoid getting an instant rejection for something like this.
Code snippet:
import MusicKit
import Foundation
import OpenGraph
extension Artist {
func artwork(width: Int = 1024, height: Int = 1024) async -> URL? {
let id = self.id.rawValue
let countryCode = try? await MusicDataRequest.currentCountryCode
let url = URL(string: "https://music.apple.com/\(countryCode ?? "us")/artist/\(id)")!
return await withCheckedContinuation { continuation in
OpenGraph.fetch(url: url) { result in
switch result {
case .success(let og):
let image = og[.image]?.resizeArtwork(width: width, height: height)
if let image = image, let url = URL(string: image) {
continuation.resume(returning: url)
} else {
continuation.resume(returning: nil)
}
case .failure(_):
continuation.resume(returning: nil)
}
}
}
}
}
extension String {
func resizeArtwork(width: Int, height: Int) -> String? {
do {
let regex = try NSRegularExpression(pattern: "/\\d+x\\d+cw", options: .caseInsensitive)
let newImage = regex.stringByReplacingMatches(in: self, options: [], range: NSRange(0..<self.utf16.count), withTemplate: "/\(width)x\(height)cc")
return newImage
} catch {
return nil
}
}
}