APRO latest version on batch and some cleanup

This commit is contained in:
ckamte
2025-12-08 13:10:48 +06:30
parent 9b589f595c
commit 43d8301307

View File

@@ -36,6 +36,7 @@ except ImportError:
or run: pip3 install tqdm.""" or run: pip3 install tqdm."""
) )
SCRIPT_NAME = "Adobe CC Packages Downloader for Windows"
VERSION = 1 VERSION = 1
VERSION_STR = "1.1.0" VERSION_STR = "1.1.0"
CODE_QUALITY = "Really_AWFUL" CODE_QUALITY = "Really_AWFUL"
@@ -58,14 +59,74 @@ ADOBE_DL_HEADERS = {"User-Agent": "Creative Cloud"}
session = requests.sessions.Session() session = requests.sessions.Session()
def show_version(): def show_version(name, version, p=4, c="=") -> None:
ye = int((32 - len(VERSION_STR)) / 2) """Show script title"""
print("=================================") tl = len(name) + (p * 2)
print("= Adobe CC Package Downloader =") print(c * tl)
print( print(c + name.center(tl - 2) + c)
"{} {} {}\n".format("=" * ye, VERSION_STR, "=" * print(f"{version.center(tl, c)}\n")
(31 - len(VERSION_STR) - ye))
def get_arguments():
parser = argparse.ArgumentParser()
parser.add_argument(
"-l", "--installLanguage", help="Language code (eg. en_US)", action="store"
) )
parser.add_argument(
"-o", "--osLanguage", help="OS Language code (eg. en_US)", action="store"
)
parser.add_argument(
"-p", "--appPlatform", help="Application platform (eg. win64)", action="store"
)
parser.add_argument(
"-s",
"--sapCode",
help="SAP code for desired product (eg. PHSP). For batch download use comma to separate products",
action="store",
)
parser.add_argument(
"-v",
"--version",
help="Version of desired product (eg. 21.0.3)",
action="store",
)
parser.add_argument(
"-d",
"--destination",
help="Directory to download installation files to",
action="store",
)
parser.add_argument(
"-u",
"--urlVersion",
help="Get app info from v4/v5/v6 url (eg. v6)",
action="store",
)
parser.add_argument(
"-A",
"--Auth",
help="Add a bearer_token to to authenticate your account, e.g. downloading Xd",
action="store",
)
parser.add_argument(
"-n",
"--noRepeatPrompt",
help="Don't prompt for additional downloads",
action="store_true",
)
parser.add_argument(
"-i",
"--productIcons",
help="Get app icons",
action="store_true",
)
parser.add_argument(
"-x",
"--skipExisting",
help="Skip existing files, e.g. resuming failed downloads",
action="store_true",
)
return parser.parse_args()
def get_install_dir(): def get_install_dir():
@@ -86,7 +147,7 @@ def url_version():
if args.urlVersion: if args.urlVersion:
if args.urlVersion.lower() in acceptVers: if args.urlVersion.lower() in acceptVers:
urlVersion = args.urlVersion[-1] urlVersion = args.urlVersion[-1]
print("\nUsing provided url version: " + urlVersion) print(f"\nUsing provided url version: {urlVersion}")
else: else:
urlVersion = None urlVersion = None
print( print(
@@ -126,7 +187,7 @@ def app_platform():
if args.appPlatform: if args.appPlatform:
if args.appPlatform in winPlatforms: if args.appPlatform in winPlatforms:
appPlatform = args.appPlatform appPlatform = args.appPlatform
print("\nUsing provided version: " + appPlatform) print(f"\nUsing provided version {appPlatform}: ")
else: else:
print( print(
f'Invalid application platform {args.appPlatform}! Please select form list below\n') f'Invalid application platform {args.appPlatform}! Please select form list below\n')
@@ -453,7 +514,7 @@ def get_products():
lastVersion = get_last_version(versions) lastVersion = get_last_version(versions)
if lastVersion: if lastVersion:
sapCodes[p["sapCode"]] = p["displayName"] sapCodes[p["sapCode"]] = p["displayName"]
print(str(len(sapCodes)) + " products found:") print(f"{str(len(sapCodes))} products found:")
return products, cdn, sapCodes, selectedPlatform return products, cdn, sapCodes, selectedPlatform
@@ -461,7 +522,7 @@ def get_products():
def get_download_path(): def get_download_path():
"""Ask for desired download folder""" """Ask for desired download folder"""
if args.destination: if args.destination:
print("\nUsing provided destination: " + args.destination + "\n") print(f"\nUsing provided destination: {args.destination}\n")
dest = args.destination dest = args.destination
else: else:
dest = os.path.dirname(os.path.realpath(__name__)) dest = os.path.dirname(os.path.realpath(__name__))
@@ -528,7 +589,7 @@ def file_download(url, dest_dir, s, v, name=None):
return download_progress(url, dest_dir) return download_progress(url, dest_dir)
def download_acrobat(appInfo, cdn): def download_acrobat(appInfo, cdn, downList):
# download manifest file # download manifest file
response = session.get( response = session.get(
cdn + appInfo["manifestURL"], stream=True, headers=ADOBE_REQ_HEADERS cdn + appInfo["manifestURL"], stream=True, headers=ADOBE_REQ_HEADERS
@@ -540,12 +601,15 @@ def download_acrobat(appInfo, cdn):
assetList = manifest.findall("./asset_list/asset") assetList = manifest.findall("./asset_list/asset")
productList = {} productList = {}
prodNum = 0 prodNum = 0
full = None
for asset in assetList: for asset in assetList:
prodNum += 1 prodNum += 1
assetPath = asset.find("./asset_path").text assetPath = asset.find("./asset_path").text
baseVersion = asset.find(".//baseVersion") baseVersion = asset.find(".//baseVersion")
if baseVersion is not None: if baseVersion is not None:
baseVersion = baseVersion.text baseVersion = baseVersion.text
else:
full = str(prodNum)
productList[str(prodNum)] = { productList[str(prodNum)] = {
"assetName": os.path.basename(assetPath), "assetName": os.path.basename(assetPath),
@@ -555,6 +619,9 @@ def download_acrobat(appInfo, cdn):
} }
selectedCode = None selectedCode = None
if len(downList) > 1:
selectedCode = full
while selectedCode is None: while selectedCode is None:
print("\nAvailable downloads\n") print("\nAvailable downloads\n")
for n, p in productList.items(): for n, p in productList.items():
@@ -575,8 +642,8 @@ def download_acrobat(appInfo, cdn):
) )
val = input( val = input(
"\nPlease enter the number of the desired product from the list above: " "\nPlease enter the number from list above or blank to download full installer: "
) ) or full
if val in productList: if val in productList:
selectedCode = val selectedCode = val
@@ -585,7 +652,7 @@ def download_acrobat(appInfo, cdn):
else: else:
print(f"{val} is not available! Please check your input.") print(f"{val} is not available! Please check your input.")
downloadURL = productList[val]["downloadUrl"] downloadURL = productList[selectedCode]["downloadUrl"]
dest = get_download_path() dest = get_download_path()
sapCode = appInfo["sapCode"] sapCode = appInfo["sapCode"]
@@ -930,7 +997,7 @@ def run_ccdl(products, cdn, sapCodes, selectedPlatform):
# download by manifest url # download by manifest url
if sapCode == "APRO": if sapCode == "APRO":
download_acrobat(prodInfo, cdn) download_acrobat(prodInfo, cdn, productLists)
continue continue
# main product # main product
@@ -992,67 +1059,9 @@ def run_ccdl(products, cdn, sapCodes, selectedPlatform):
if __name__ == "__main__": if __name__ == "__main__":
show_version() show_version(SCRIPT_NAME, VERSION_STR)
parser = argparse.ArgumentParser() args = get_arguments()
parser.add_argument(
"-l", "--installLanguage", help="Language code (eg. en_US)", action="store"
)
parser.add_argument(
"-o", "--osLanguage", help="OS Language code (eg. en_US)", action="store"
)
parser.add_argument(
"-p", "--appPlatform", help="Application platform (eg. win64)", action="store"
)
parser.add_argument(
"-s",
"--sapCode",
help="SAP code for desired product (eg. PHSP). For batch download use comma to separate products",
action="store",
)
parser.add_argument(
"-v",
"--version",
help="Version of desired product (eg. 21.0.3)",
action="store",
)
parser.add_argument(
"-d",
"--destination",
help="Directory to download installation files to",
action="store",
)
parser.add_argument(
"-u",
"--urlVersion",
help="Get app info from v4/v5/v6 url (eg. v6)",
action="store",
)
parser.add_argument(
"-A",
"--Auth",
help="Add a bearer_token to to authenticate your account, e.g. downloading Xd",
action="store",
)
parser.add_argument(
"-n",
"--noRepeatPrompt",
help="Don't prompt for additional downloads",
action="store_true",
)
parser.add_argument(
"-i",
"--productIcons",
help="Get app icons",
action="store_true",
)
parser.add_argument(
"-x",
"--skipExisting",
help="Skip existing files, e.g. resuming failed downloads",
action="store_true",
)
args = parser.parse_args()
products, cdn, sapCodes, selectedPlatform = get_products() products, cdn, sapCodes, selectedPlatform = get_products()