diff --git a/Sources/AppleReserver/Constant.swift b/Sources/AppleReserver/Constant.swift index fd0be88..5c0408f 100644 --- a/Sources/AppleReserver/Constant.swift +++ b/Sources/AppleReserver/Constant.swift @@ -15,4 +15,8 @@ public struct AppleURL { static func availability(of region: String) -> URL { return URL(string: "https://reserve-prime.apple.com/\(region)/zh_\(region)/reserve/A/availability.json")! } + + static func reserve(of region: String) -> URL { + return URL(string: "https://reserve-prime.apple.com/\(region)/zh_\(region)/reserve/A/availability")! + } } diff --git a/Sources/AppleReserver/Script.swift b/Sources/AppleReserver/Script.swift deleted file mode 100644 index 485bdec..0000000 --- a/Sources/AppleReserver/Script.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// Script.swift -// -// -// Created by Sunny Young on 2021/9/19. -// - -import Foundation -import PromiseKit - -struct Script { - static func execute(command: String) -> Promise { - Promise { seal in - do { - var error: NSDictionary? - guard let script = NSAppleScript(source: "do shell script \"\(command)\"") else { - throw NSError(domain: "applereserver", code: -1, userInfo: [NSLocalizedDescriptionKey: "Create script failed."]) - } - script.executeAndReturnError(&error) - if let error = error { - throw NSError(domain: "applereserver", code: -1, userInfo: [NSLocalizedDescriptionKey: error]) - } else { - seal.fulfill(()) - } - } catch { - seal.reject(error) - } - } - } -} diff --git a/Sources/AppleReserver/main.swift b/Sources/AppleReserver/main.swift index 5a08e46..d04a7b9 100644 --- a/Sources/AppleReserver/main.swift +++ b/Sources/AppleReserver/main.swift @@ -82,7 +82,7 @@ struct Monitor: ParsableCommand { print("\u{1B}[1A\u{1B}[KChecked for \(Monitor.count) times.") } else { results.forEach { (store: String, part: String) in - print("⚠️ \(Date())\t\(store)\t\(part) 有货啦!!!\n") + print("🚨 \(Date().description(with: .current))\t\(store)\t\(part) 有货啦!!!\n\(AppleURL.reserve(of: region))") } } }.catch { error in