From 07903131f90c17bd52df6e6996923884cae7c16a Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Wed, 3 May 2023 14:20:54 -0400 Subject: [PATCH] GetTwitchDownloader.py now supports LinuxArm-x64 (not implemeted yet), waiting for this: https://github.com/lay295/TwitchDownloader/pull/703 --- docker-utils/GetTwitchDownloader.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/docker-utils/GetTwitchDownloader.py b/docker-utils/GetTwitchDownloader.py index 619054c..457c7f3 100644 --- a/docker-utils/GetTwitchDownloader.py +++ b/docker-utils/GetTwitchDownloader.py @@ -3,13 +3,26 @@ import requests import shutil import os import re +import sys +from collections import OrderedDict from github import Github machine = platform.machine() -def isARM(): - return True if machine.startswith('arm') else False +# https://stackoverflow.com/questions/45125516/possible-values-for-uname-m +MACHINES_TO_ZIP = OrderedDict([ + ("x86_64", "Linux-x64"), + ("aarch64", "LinuxArm-x64"), + ("armv8", "LinuxArm-x64"), + ("arm", "LinuxArm"), + ("AMD64", "Windows-x64") +]) + +def getZipName(): + for possibleMachine, possibleZipName in MACHINES_TO_ZIP.items(): + if possibleMachine in machine: + return possibleZipName def getLatestFileInRepo(repo, search_string): # Create an unauthenticated instance of the Github object @@ -46,8 +59,11 @@ def getLatestFileInRepo(repo, search_string): print(f'No release found with {search_string}') def getLatestCLIRelease(): - isArm = isARM() - searchString = r'.*CLI.*' + "LinuxArm.zip" if isArm else "Linux-x64.zip" + zipName = getZipName() + if not zipName: + print(f"GetTwitchDownloader.py could not get valid path for '{machine}'. Exiting...") + sys.exit(1) + searchString = r'.*CLI.*' + zipName getLatestFileInRepo("lay295/TwitchDownloader", searchString) getLatestCLIRelease()