Add batch download function

This commit is contained in:
ckamte
2025-11-25 13:18:18 +06:30
parent 4b26d8c02d
commit 451209f127
2 changed files with 123 additions and 92 deletions

View File

@@ -15,7 +15,7 @@ Arguments:
"-l", "--installLanguage", "Language code (eg. en_US)" "-l", "--installLanguage", "Language code (eg. en_US)"
"-o", "--osLanguage", "OS Language code (eg. en_US)" "-o", "--osLanguage", "OS Language code (eg. en_US)"
"-p", "--appPlatform", "Application platform (eg. win64)" "-p", "--appPlatform", "Application platform (eg. win64)"
"-s", "--sapCode", "SAP code for desired product (eg. PHSP)" "-s", "--sapCode", "SAP code for desired product (eg. PHSP). For batch download use comma to separate products"
"-v", "--version", "Version of desired product (eg. 21.0.3)" "-v", "--version", "Version of desired product (eg. 21.0.3)"
"-d", "--destination", "Directory to download installation files to" "-d", "--destination", "Directory to download installation files to"
"-u", "--urlVersion", "Get app info from v4/v5/v6 url (eg. v6)" "-u", "--urlVersion", "Get app info from v4/v5/v6 url (eg. v6)"
@@ -36,3 +36,11 @@ Arguments:
6. Optional - Delete downloaded zip files in "acc_sources" directory to reduce installer size (Not necessary because omitting the folder if the whole installation is packed is valid and if kept, used for other products) 6. Optional - Delete downloaded zip files in "acc_sources" directory to reduce installer size (Not necessary because omitting the folder if the whole installation is packed is valid and if kept, used for other products)
7. Run Set-up.exe to install the product. 7. Run Set-up.exe to install the product.
8. Note - Make sure AdobePIM.dll file version in "resources" folder matches the Set-Up.exe file version. 8. Note - Make sure AdobePIM.dll file version in "resources" folder matches the Set-Up.exe file version.
## Note
1. You can manually download CC Library packge using *libs* sapcode and *kfnt* for Adobe fonts.
2. Batch download is available now.
```
python ccdl-win.py -u 6 -l en_US -p win64 -s phsp,idsn,ilst -x
```

View File

@@ -160,37 +160,18 @@ def app_platform():
return appPlatform return appPlatform
def select_product(products, sapCodes):
def product_code(sapCodes):
selectedCode = args.sapCode
if selectedCode:
selectedCode = selectedCode.upper()
if selectedCode and selectedCode not in sapCodes:
print("\nProvided SAP code ({}) is not available\n".format(selectedCode))
answer = None
while answer is None:
answer = input("Are you want to continue? (y/n): ")
if answer.lower() in ["y", "yes"]:
print("")
selectedCode = None
elif answer.lower() in ["n", "no"]:
print("\nProgram terminated!\n")
exit()
else:
print("\nPlease enter yes or no!")
answer = None
if not selectedCode or selectedCode is None:
for s, d in sapCodes.items(): for s, d in sapCodes.items():
print("[{}]{}{}".format(s, (10 - len(s)) * " ", d)) print("[{}]{}{}".format(s, (10 - len(s)) * " ", d))
while selectedCode is None: slectedProduct = None
while slectedProduct is None:
val = input( val = input(
"\nPlease enter the SAP Code of the desired product from the list above: " "\nPlease enter the SAP Code of the desired product from the list above: "
).upper() ).upper()
if products.get(val): if products.get(val):
selectedCode = val slectedProduct = val
elif val == "": elif val == "":
print("No product selected! Please use a value from the list above.") print("No product selected! Please use a value from the list above.")
else: else:
@@ -199,8 +180,46 @@ def product_code(sapCodes):
val val
) )
) )
return selectedCode return slectedProduct
# for batch download
def product_code(products, sapCodes):
codeList = []
toDown = args.sapCode
if toDown:
toDown = toDown.upper().split(',')
for prodToDown in toDown:
if prodToDown in sapCodes:
print("\nAdd {} to download list".format(prodToDown))
codeList.append(prodToDown)
else:
print("\n{} is not available!\n".format(prodToDown))
answer = None
while answer is None:
answer = input("Are you want to continue? (y/n): ")
if answer.lower() in ["y", "yes"]:
answer = select_product(products, sapCodes)
# for duplicate entry
while answer in codeList:
print("\nAdd {} already exist in donload list".format(answer))
answer = input(
"\nPlease enter the SAP Code of the desired product from the list above: "
).upper()
else:
print("\nAdd {} to download list".format(answer))
codeList.append(answer)
elif answer.lower() in ["n", "no"]:
print("\nProgram terminated!\n")
else:
print("\nPlease enter yes or no!")
answer = None
else:
toDown = select_product(products, sapCodes)
codeList.append(toDown)
return codeList
def product_version(product, versions): def product_version(product, versions):
version = None version = None
@@ -344,7 +363,7 @@ def parse_products_xml(products_url, url_version, allowed_platform, selected_pla
#with open("ffc.xml", "wb+") as f: #with open("ffc.xml", "wb+") as f:
# f.write(response.content) # f.write(response.content)
# products_xml = ET.parse("ffc.xml") #products_xml = ET.parse("ffc.xml")
cdn = products_xml.find(".//*/cdn/secure").text cdn = products_xml.find(".//*/cdn/secure").text
allProducts = {} allProducts = {}
@@ -898,7 +917,9 @@ def package_download(json, pkg_dir, language, selectedPlatform):
def run_ccdl(products, cdn, sapCodes, selectedPlatform): def run_ccdl(products, cdn, sapCodes, selectedPlatform):
"""Run Main execution.""" """Run Main execution."""
# get product list # get product list
sapCode = product_code(sapCodes) productLists = product_code(products, sapCodes)
for sapCode in productLists:
product = products.get(sapCode) product = products.get(sapCode)
# version select # version select
@@ -990,7 +1011,7 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"-s", "-s",
"--sapCode", "--sapCode",
help="SAP code for desired product (eg. PHSP)", help="SAP code for desired product (eg. PHSP). For batch download use comma to separate products",
action="store", action="store",
) )
parser.add_argument( parser.add_argument(
@@ -1042,6 +1063,8 @@ if __name__ == "__main__":
while True: while True:
try: try:
run_ccdl(products, cdn, sapCodes, selectedPlatform) run_ccdl(products, cdn, sapCodes, selectedPlatform)
# cleanup old sapcodes
args.sapCode = None
if args.noRepeatPrompt or not questiony( if args.noRepeatPrompt or not questiony(
"\n\nDo you want to download another package" "\n\nDo you want to download another package"
): ):