mirror of
https://github.com/majd/ipatool
synced 2026-12-03 04:19:05 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
972f0b2cd0 | ||
|
|
03993b2b93 |
No files matched your search
@@ -34,7 +34,7 @@ To search for apps on the App Store, use the `search` command.
|
||||
```
|
||||
OVERVIEW: Search for iOS apps available on the App Store.
|
||||
|
||||
USAGE: ipatool search <term> [--limit <limit>] [--country <country>] [--log-level <log-level>]
|
||||
USAGE: ipatool search <term> [--limit <limit>] [--country <country>] [--device-family <device-family>] [--log-level <log-level>]
|
||||
|
||||
ARGUMENTS:
|
||||
<term> The term to search for.
|
||||
@@ -44,7 +44,10 @@ OPTIONS:
|
||||
(default: 5)
|
||||
-c, --country <country> The two-letter (ISO 3166-1 alpha-2) country code for
|
||||
the iTunes Store. (default: US)
|
||||
--log-level <log-level> (default: info)
|
||||
-d, --device-family <device-family>
|
||||
The device family to limit the search query to.
|
||||
(default: iPhone)
|
||||
--log-level <log-level> The log level. (default: info)
|
||||
--version Show the version.
|
||||
-h, --help Show help information.
|
||||
```
|
||||
@@ -54,7 +57,7 @@ To download a copy of the ipa file, use the `download` command.
|
||||
```
|
||||
OVERVIEW: Download (encrypted) iOS app packages from the App Store.
|
||||
|
||||
USAGE: ipatool download --bundle-identifier <bundle-identifier> [--email <email>] [--password <password>] [--country <country>] [--log-level <log-level>]
|
||||
USAGE: ipatool download --bundle-identifier <bundle-identifier> [--email <email>] [--password <password>] [--country <country>] [--device-family <device-family>] [--log-level <log-level>]
|
||||
|
||||
OPTIONS:
|
||||
-b, --bundle-identifier <bundle-identifier>
|
||||
@@ -64,7 +67,10 @@ OPTIONS:
|
||||
The password for the Apple ID.
|
||||
-c, --country <country> The two-letter (ISO 3166-1 alpha-2) country code for
|
||||
the iTunes Store. (default: US)
|
||||
--log-level <log-level> (default: info)
|
||||
-d, --device-family <device-family>
|
||||
The device family to limit the search query to.
|
||||
(default: iPhone)
|
||||
--log-level <log-level> The log level. (default: info)
|
||||
--version Show the version.
|
||||
-h, --help Show help information.
|
||||
```
|
||||
|
||||
@@ -25,9 +25,12 @@ struct Download: ParsableCommand {
|
||||
@Option(name: [.short, .long], help: "The two-letter (ISO 3166-1 alpha-2) country code for the iTunes Store.")
|
||||
private var country: String = "US"
|
||||
|
||||
@Option
|
||||
@Option(name: [.short, .long], help: "The device family to limit the search query to.")
|
||||
private var deviceFamily: iTunesRequest.DeviceFamily = .phone
|
||||
|
||||
@Option(name: [.long], help: "The log level.")
|
||||
private var logLevel: LogLevel = .info
|
||||
|
||||
|
||||
lazy var logger = ConsoleLogger(level: logLevel)
|
||||
}
|
||||
|
||||
@@ -41,7 +44,7 @@ extension Download {
|
||||
|
||||
do {
|
||||
logger.log("Querying the iTunes Store for '\(bundleIdentifier)' in country '\(country)'...", level: .info)
|
||||
return try itunesClient.lookup(bundleIdentifier: bundleIdentifier, country: country)
|
||||
return try itunesClient.lookup(bundleIdentifier: bundleIdentifier, country: country, deviceFamily: deviceFamily)
|
||||
} catch {
|
||||
logger.log("\(error)", level: .debug)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ struct IPATool: ParsableCommand {
|
||||
static var configuration: CommandConfiguration {
|
||||
return .init(commandName: "ipatool",
|
||||
abstract: "A cli tool for interacting with Apple's ipa files.",
|
||||
version: "1.0.4",
|
||||
version: "1.0.5",
|
||||
subcommands: [Download.self, Search.self])
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,10 @@ struct Search: ParsableCommand {
|
||||
@Option(name: [.short, .long], help: "The two-letter (ISO 3166-1 alpha-2) country code for the iTunes Store.")
|
||||
private var country: String = "US"
|
||||
|
||||
@Option
|
||||
@Option(name: [.short, .long], help: "The device family to limit the search query to.")
|
||||
private var deviceFamily: iTunesRequest.DeviceFamily = .phone
|
||||
|
||||
@Option(name: [.long], help: "The log level.")
|
||||
private var logLevel: LogLevel = .info
|
||||
|
||||
lazy var logger = ConsoleLogger(level: logLevel)
|
||||
@@ -38,7 +41,7 @@ extension Search {
|
||||
|
||||
do {
|
||||
logger.log("Searching for '\(term)' using the '\(country)' store front...", level: .info)
|
||||
let results = try itunesClient.search(term: term, limit: limit, country: country)
|
||||
let results = try itunesClient.search(term: term, limit: limit, country: country, deviceFamily: deviceFamily)
|
||||
|
||||
guard !results.isEmpty else {
|
||||
logger.log("No results found.", level: .error)
|
||||
|
||||
@@ -8,16 +8,23 @@
|
||||
import Foundation
|
||||
|
||||
protocol iTunesClientInterface {
|
||||
func lookup(bundleIdentifier: String, country: String, completion: @escaping (Result<iTunesResponse.Result, Error>) -> Void)
|
||||
func search(term: String, limit: Int, country: String, completion: @escaping (Result<[iTunesResponse.Result], Error>) -> Void)
|
||||
func lookup(bundleIdentifier: String,
|
||||
country: String,
|
||||
deviceFamily: iTunesRequest.DeviceFamily,
|
||||
completion: @escaping (Result<iTunesResponse.Result, Error>) -> Void)
|
||||
func search(term: String,
|
||||
limit: Int,
|
||||
country: String,
|
||||
deviceFamily: iTunesRequest.DeviceFamily,
|
||||
completion: @escaping (Result<[iTunesResponse.Result], Error>) -> Void)
|
||||
}
|
||||
|
||||
extension iTunesClientInterface {
|
||||
func lookup(bundleIdentifier: String, country: String) throws -> iTunesResponse.Result {
|
||||
func lookup(bundleIdentifier: String, country: String, deviceFamily: iTunesRequest.DeviceFamily) throws -> iTunesResponse.Result {
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
var result: Result<iTunesResponse.Result, Error>?
|
||||
|
||||
lookup(bundleIdentifier: bundleIdentifier, country: country) {
|
||||
lookup(bundleIdentifier: bundleIdentifier, country: country, deviceFamily: deviceFamily) {
|
||||
result = $0
|
||||
semaphore.signal()
|
||||
}
|
||||
@@ -34,11 +41,11 @@ extension iTunesClientInterface {
|
||||
}
|
||||
}
|
||||
|
||||
func search(term: String, limit: Int, country: String) throws -> [iTunesResponse.Result] {
|
||||
func search(term: String, limit: Int, country: String, deviceFamily: iTunesRequest.DeviceFamily) throws -> [iTunesResponse.Result] {
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
var result: Result<[iTunesResponse.Result], Error>?
|
||||
|
||||
search(term: term, limit: limit, country: country) {
|
||||
search(term: term, limit: limit, country: country, deviceFamily: deviceFamily) {
|
||||
result = $0
|
||||
semaphore.signal()
|
||||
}
|
||||
@@ -63,8 +70,11 @@ final class iTunesClient: iTunesClientInterface {
|
||||
self.httpClient = httpClient
|
||||
}
|
||||
|
||||
func lookup(bundleIdentifier: String, country: String, completion: @escaping (Result<iTunesResponse.Result, Swift.Error>) -> Void) {
|
||||
let request = iTunesRequest.lookup(bundleIdentifier: bundleIdentifier, country: country)
|
||||
func lookup(bundleIdentifier: String,
|
||||
country: String,
|
||||
deviceFamily: iTunesRequest.DeviceFamily,
|
||||
completion: @escaping (Result<iTunesResponse.Result, Swift.Error>) -> Void) {
|
||||
let request = iTunesRequest.lookup(bundleIdentifier: bundleIdentifier, country: country, deviceFamily: deviceFamily)
|
||||
|
||||
httpClient.send(request) { result in
|
||||
switch result {
|
||||
@@ -82,8 +92,12 @@ final class iTunesClient: iTunesClientInterface {
|
||||
}
|
||||
}
|
||||
|
||||
func search(term: String, limit: Int, country: String, completion: @escaping (Result<[iTunesResponse.Result], Swift.Error>) -> Void) {
|
||||
let request = iTunesRequest.search(term: term, limit: limit, country: country)
|
||||
func search(term: String,
|
||||
limit: Int,
|
||||
country: String,
|
||||
deviceFamily: iTunesRequest.DeviceFamily,
|
||||
completion: @escaping (Result<[iTunesResponse.Result], Swift.Error>) -> Void) {
|
||||
let request = iTunesRequest.search(term: term, limit: limit, country: country, deviceFamily: deviceFamily)
|
||||
|
||||
httpClient.send(request) { result in
|
||||
switch result {
|
||||
|
||||
@@ -5,11 +5,31 @@
|
||||
// Created by Majd Alfhaily on 22.05.21.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import ArgumentParser
|
||||
|
||||
enum iTunesRequest {
|
||||
case search(term: String, limit: Int, country: String)
|
||||
case lookup(bundleIdentifier: String, country: String)
|
||||
case search(term: String, limit: Int, country: String, deviceFamily: DeviceFamily = .phone)
|
||||
case lookup(bundleIdentifier: String, country: String, deviceFamily: DeviceFamily = .phone)
|
||||
}
|
||||
|
||||
extension iTunesRequest {
|
||||
enum DeviceFamily: String, ExpressibleByArgument {
|
||||
case phone = "iPhone"
|
||||
case pad = "iPad"
|
||||
|
||||
var defaultValueDescription: String {
|
||||
return rawValue
|
||||
}
|
||||
|
||||
var entity: String {
|
||||
switch self {
|
||||
case .phone:
|
||||
return "software"
|
||||
case .pad:
|
||||
return "iPadSoftware"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension iTunesRequest: HTTPRequest {
|
||||
@@ -28,10 +48,10 @@ extension iTunesRequest: HTTPRequest {
|
||||
|
||||
var payload: HTTPPayload? {
|
||||
switch self {
|
||||
case let .lookup(bundleIdentifier, country):
|
||||
return .urlEncoding(["media": "software", "bundleId": bundleIdentifier, "limit": "1", "country": country])
|
||||
case let .search(term, limit, country):
|
||||
return .urlEncoding(["media": "software", "term": term, "limit": "\(limit)", "country": country])
|
||||
case let .lookup(bundleIdentifier, country, deviceFamily):
|
||||
return .urlEncoding(["media": "software", "bundleId": bundleIdentifier, "limit": "1", "country": country, "entity": deviceFamily.entity])
|
||||
case let .search(term, limit, country, deviceFamily):
|
||||
return .urlEncoding(["media": "software", "term": term, "limit": "\(limit)", "country": country, "entity": deviceFamily.entity])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,14 @@
|
||||
<CommandLineArguments>
|
||||
<CommandLineArgument
|
||||
argument = "download --help"
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "search "Swift Playgrounds" --device-family iPhone"
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "search "Swift Playgrounds" --device-family iPad"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
|
||||
Reference in new issue
Block a user