mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 11:13:28 +01:00
FetchAnisetteDataOperation.swift fix url reading
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
This commit is contained in:
@@ -32,34 +32,31 @@ class FetchAnisetteDataOperation: ResultOperation<ALTAnisetteData>
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let urlString = UserDefaults.standard.string(forKey: "customAnisetteURL")!
|
let url = AnisetteManager.currentURL
|
||||||
print("Anisette URL: " + urlString)
|
DLOG("Anisette URL: %@", url.absoluteString)
|
||||||
guard let url = URL(string: urlString) else { return }
|
|
||||||
|
let task = URLSession.shared.dataTask(with: url) { data, response, error in
|
||||||
let task = URLSession.shared.dataTask(with: url) { data, response, error in
|
guard let data = data, error == nil else { return }
|
||||||
|
|
||||||
guard let data = data, error == nil else { return }
|
do {
|
||||||
|
// make sure this JSON is in the format we expect
|
||||||
do {
|
// convert data to json
|
||||||
// make sure this JSON is in the format we expect
|
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] {
|
||||||
// convert data to json
|
// try to read out a dictionary
|
||||||
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] {
|
//for some reason serial number isn't needed but it doesn't work unless it has a value
|
||||||
// try to read out a dictionary
|
let formattedJSON: [String: String] = ["machineID": json["X-Apple-I-MD-M"]!, "oneTimePassword": json["X-Apple-I-MD"]!, "localUserID": json["X-Apple-I-MD-LU"]!, "routingInfo": json["X-Apple-I-MD-RINFO"]!, "deviceUniqueIdentifier": json["X-Mme-Device-Id"]!, "deviceDescription": json["X-MMe-Client-Info"]!, "date": json["X-Apple-I-Client-Time"]!, "locale": json["X-Apple-Locale"]!, "timeZone": json["X-Apple-I-TimeZone"]!, "deviceSerialNumber": "1"]
|
||||||
//for some reason serial number isn't needed but it doesn't work unless it has a value
|
|
||||||
let formattedJSON: [String: String] = ["machineID": json["X-Apple-I-MD-M"]!, "oneTimePassword": json["X-Apple-I-MD"]!, "localUserID": json["X-Apple-I-MD-LU"]!, "routingInfo": json["X-Apple-I-MD-RINFO"]!, "deviceUniqueIdentifier": json["X-Mme-Device-Id"]!, "deviceDescription": json["X-MMe-Client-Info"]!, "date": json["X-Apple-I-Client-Time"]!, "locale": json["X-Apple-Locale"]!, "timeZone": json["X-Apple-I-TimeZone"]!, "deviceSerialNumber": "1"]
|
if let anisette = ALTAnisetteData(json: formattedJSON) {
|
||||||
|
self.finish(.success(anisette))
|
||||||
if let anisette = ALTAnisetteData(json: formattedJSON) {
|
}
|
||||||
self.finish(.success(anisette))
|
}
|
||||||
}
|
} catch let error as NSError {
|
||||||
}
|
print("Failed to load: \(error.localizedDescription)")
|
||||||
} catch let error as NSError {
|
self.finish(.failure(error))
|
||||||
print("Failed to load: \(error.localizedDescription)")
|
}
|
||||||
self.finish(.failure(error))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
task.resume()
|
||||||
|
|
||||||
task.resume()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user