mirror of
https://github.com/corpnewt/gibMacOS.git
synced 2024-09-20 01:30:33 +00:00
Allow to filter products by Device ID using --device-id option
This allows to easily filter only builds supporting x86_64.
This commit is contained in:
parent
9018aa6e5b
commit
a93490cf99
1 changed files with 25 additions and 8 deletions
33
gibMacOS.py
33
gibMacOS.py
|
@ -224,7 +224,13 @@ class gibMacOS:
|
||||||
name = re.search(r"<title>(.+?)</title>",dist_file).group(1)
|
name = re.search(r"<title>(.+?)</title>",dist_file).group(1)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return (build,version,name)
|
try:
|
||||||
|
# XXX: This is parsing a JavaScript array from the script part of the dist file.
|
||||||
|
device_ids = re.search(r"var supportedDeviceIDs\s*=\s*\[([^]]+)\];", dist_file)[1]
|
||||||
|
device_ids = set(i.lower() for i in re.findall(r"'([^',]+)'", device_ids))
|
||||||
|
except:
|
||||||
|
device_ids = set()
|
||||||
|
return (build,version,name,device_ids)
|
||||||
|
|
||||||
def get_dict_for_prods(self, prods, plist_dict = None):
|
def get_dict_for_prods(self, prods, plist_dict = None):
|
||||||
if plist_dict==self.catalog_data==None:
|
if plist_dict==self.catalog_data==None:
|
||||||
|
@ -262,8 +268,8 @@ class gibMacOS:
|
||||||
prodd["packages"] = plist_dict.get("Products",{}).get(prod,{}).get("Packages",[])
|
prodd["packages"] = plist_dict.get("Products",{}).get(prod,{}).get("Packages",[])
|
||||||
# Get size
|
# Get size
|
||||||
prodd["size"] = self.d.get_size(sum([i["Size"] for i in prodd["packages"]]))
|
prodd["size"] = self.d.get_size(sum([i["Size"] for i in prodd["packages"]]))
|
||||||
# Attempt to get the build/version info from the dist
|
# Attempt to get the build/version/name/device-ids info from the dist
|
||||||
prodd["build"],v,n = self.get_build_version(plist_dict.get("Products",{}).get(prod,{}).get("Distributions",{}))
|
prodd["build"],v,n,prodd["device_ids"] = self.get_build_version(plist_dict.get("Products",{}).get(prod,{}).get("Distributions",{}))
|
||||||
prodd["title"] = smd.get("localization",{}).get("English",{}).get("title",n)
|
prodd["title"] = smd.get("localization",{}).get("English",{}).get("title",n)
|
||||||
print(" -->{}. {} ({}){}".format(
|
print(" -->{}. {} ({}){}".format(
|
||||||
str(len(prod_list)+1).rjust(3),
|
str(len(prod_list)+1).rjust(3),
|
||||||
|
@ -527,10 +533,18 @@ class gibMacOS:
|
||||||
return
|
return
|
||||||
self.download_prod(self.mac_prods[menu-1], dmg)
|
self.download_prod(self.mac_prods[menu-1], dmg)
|
||||||
|
|
||||||
def get_latest(self, dmg = False):
|
def get_latest(self, device_id = None, dmg = False):
|
||||||
self.u.head("Downloading Latest")
|
self.u.head("Downloading Latest")
|
||||||
print("")
|
print("")
|
||||||
self.download_prod(sorted(self.mac_prods, key=lambda x:x['version'], reverse=True)[0], dmg)
|
prods = sorted(self.mac_prods, key=lambda x:x['version'], reverse=True)
|
||||||
|
if device_id:
|
||||||
|
prod = next(p for p in prods if device_id.lower() in p["device_ids"])
|
||||||
|
if not prod:
|
||||||
|
print("No version found for Device ID '{}'".format(device_id))
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
prod = prods[0]
|
||||||
|
self.download_prod(prod, dmg)
|
||||||
|
|
||||||
def get_for_product(self, prod, dmg = False):
|
def get_for_product(self, prod, dmg = False):
|
||||||
self.u.head("Downloading for {}".format(prod))
|
self.u.head("Downloading for {}".format(prod))
|
||||||
|
@ -541,7 +555,7 @@ class gibMacOS:
|
||||||
return
|
return
|
||||||
print("{} not found".format(prod))
|
print("{} not found".format(prod))
|
||||||
|
|
||||||
def get_for_version(self, vers, build = None, dmg = False):
|
def get_for_version(self, vers, build = None, device_id = None, dmg = False):
|
||||||
self.u.head("Downloading for {} {}".format(vers, build or ""))
|
self.u.head("Downloading for {} {}".format(vers, build or ""))
|
||||||
print("")
|
print("")
|
||||||
# Map the versions to their names
|
# Map the versions to their names
|
||||||
|
@ -553,6 +567,8 @@ class gibMacOS:
|
||||||
for p in sorted(self.mac_prods, key=lambda x:x['version'], reverse=True):
|
for p in sorted(self.mac_prods, key=lambda x:x['version'], reverse=True):
|
||||||
if build and p["build"] != build:
|
if build and p["build"] != build:
|
||||||
continue
|
continue
|
||||||
|
if device_id and device_id.lower() not in p["device_ids"]:
|
||||||
|
continue
|
||||||
pt = p["title"].lower()
|
pt = p["title"].lower()
|
||||||
pv = p["version"].lower()
|
pv = p["version"].lower()
|
||||||
# Need to compare verisons - n = name, v = version
|
# Need to compare verisons - n = name, v = version
|
||||||
|
@ -591,6 +607,7 @@ if __name__ == '__main__':
|
||||||
parser.add_argument("-v", "--version", help="sets the version of macOS to target - eg '-v 10.14' or '-v Yosemite'")
|
parser.add_argument("-v", "--version", help="sets the version of macOS to target - eg '-v 10.14' or '-v Yosemite'")
|
||||||
parser.add_argument("-b", "--build", help="sets the build of macOS to target - eg '22G120' (must be used together with --version)")
|
parser.add_argument("-b", "--build", help="sets the build of macOS to target - eg '22G120' (must be used together with --version)")
|
||||||
parser.add_argument("-m", "--maxos", help="sets the max macOS version to consider when building the url - eg 10.14")
|
parser.add_argument("-m", "--maxos", help="sets the max macOS version to consider when building the url - eg 10.14")
|
||||||
|
parser.add_argument("-D", "--device-id", help="use with --version or --latest to search for versions supporting the specified Device ID - eg VMM-x86_64 for any x86_64")
|
||||||
parser.add_argument("-i", "--print-urls", help="only prints the download URLs, does not actually download them", action="store_true")
|
parser.add_argument("-i", "--print-urls", help="only prints the download URLs, does not actually download them", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -622,13 +639,13 @@ if __name__ == '__main__':
|
||||||
g.set_prods()
|
g.set_prods()
|
||||||
|
|
||||||
if args.latest:
|
if args.latest:
|
||||||
g.get_latest(args.dmg)
|
g.get_latest(device_id=args.device_id, dmg=args.dmg)
|
||||||
exit()
|
exit()
|
||||||
if args.product != None:
|
if args.product != None:
|
||||||
g.get_for_product(args.product, args.dmg)
|
g.get_for_product(args.product, args.dmg)
|
||||||
exit()
|
exit()
|
||||||
if args.version != None:
|
if args.version != None:
|
||||||
g.get_for_version(args.version, args.build, args.dmg)
|
g.get_for_version(args.version, args.build, device_id=args.device_id, dmg=args.dmg)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in a new issue