# -*- coding: utf-8 -*-
from setuphelpers import *

install_path = makepath(programfiles,"Deezer")
uninstall_path = makepath(install_path,"Uninstall Deezer.exe")

def install():
   # Installing the software
    
    bin_name = glob.glob("deezer*.exe")[0]
    
    while True:
        try:
            install_exe_if_needed(bin_name,silentflags=f'/S /D="{install_path}"')
            break
        except:
            if not params.get("install_with_luti", False):
                raise
            else:
                time.sleep(10)
                
    uninstall_string = '"' + uninstall_path + '"' + " /S"
    register_uninstall(uninstallkey="Deezer_is1", uninstallstring=rf"{uninstall_string}", quiet_uninstall_string=rf"{uninstall_string}",install_location=rf'"{install_path}"', display_name="Deezer",display_version=get_version_from_binary(bin_name))

def uninstall():
    if installed_softwares("Deezer_is1"):
        run(uninstall_cmd("Deezer_is1"))
        unregister_uninstall("Deezer_is1")