Python script that will download, unarchive, and install the latest elvui into your wow>retail>interface>addons folder
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

115 lines
3.1 KiB

#!/usr/bin/python3
import sys
import urllib.request
import shutil
from zipfile import ZipFile
import getopt
import os
from bs4 import BeautifulSoup
# use BeauitfulSoup4 to grab version number
def get_update_version():
# ELVui download page to scrape version from
url = "https://www.tukui.org/download.php?ui=elvui"
# build out the content request
content = urllib.request.urlopen(url).read()
# get your soup on
soup = BeautifulSoup(content, features="html.parser")
# capture version number and return as def response
response = soup.find_all(class_='Premium')[0].get_text()
return response
# download the elvui update file using get_update_version response
def get_update(update_version):
update_url = 'https://www.tukui.org/downloads/elvui-' + update_version + '.zip'
save_path = 'elvui_update.zip'
try:
with urllib.request.urlopen(update_url) as response, open(save_path, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
except urllib.error.URLError as e:
print(f"Update Version {update_version} {e.reason}")
sys.exit(1)
print(f"Download of {update_url} completed.")
def install_update(wowPath):
install_path = wowPath + '/_retail_/Interface/AddOns/'
with ZipFile('elvui_update.zip', 'r') as zipObj:
zipObj.extractall(install_path)
print(f"Extraction over old add-on completed at {install_path}.")
def remove_download():
os.remove('elvui_update.zip')
print("ElvUI update file removed.")
def show_changelog():
url = "https://www.tukui.org/download.php?ui=elvui"
# build out the content request
content = urllib.request.urlopen(url).read()
# get your soup on
soup = BeautifulSoup(content, features="html.parser")
# capture version number and return as def response
response = soup.find_all('div', id='changelog')[0].get_text()
print(response)
# Define the usage of the app
def usage():
"""Prints usage information"""
print("""
ElvUI Updater by prasket
Usage: python update.py
-h --help - this message
-w --wow_path - *OPTIONAL* path to your base WOW install
(Default = /Applications/World of Warcraft/)
Examples:
Running with default install path:
python update.py
Running with custom install path:
python update.py --wow_path /apps/wow
""")
sys.exit(0)
def main(argv):
# set default wow path making -w argv optional
wowPath = "/Applications/World of Warcraft" # default wow install dir on MacOS.
try:
opts, args = getopt.getopt(argv,"hw:",["help","wow_path="])
except getopt.GetoptError as err:
print(str(err))
usage()
for o, a in opts:
if o in ("-h", "--help"):
usage()
elif o in ("-w", "--wow_path"):
wowPath = a
else:
assert False, "Unhandled Option"
# grab update version #
update_version = get_update_version()
get_update(update_version)
install_update(wowPath)
remove_download()
show_changelog()
print(f"ElvUI has been updated to {update_version}")
if __name__ == "__main__":
main(sys.argv[1:])