From 6a6ec400dbf682bac4e5eec634bb1b7af15cb80f Mon Sep 17 00:00:00 2001 From: RemixDev Date: Tue, 21 Dec 2021 15:13:27 +0100 Subject: [PATCH] try catch getting music folder from reg registry --- deemix/utils/localpaths.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/deemix/utils/localpaths.py b/deemix/utils/localpaths.py index b8ac8d5..5989698 100644 --- a/deemix/utils/localpaths.py +++ b/deemix/utils/localpaths.py @@ -52,16 +52,19 @@ def getMusicFolder(): musicdata = Path(os.path.expandvars(musicdata)) musicdata = checkPath(musicdata) if os.name == 'nt' and musicdata == "": - musicKeys = ['My Music', '{4BD8D571-6D19-48D3-BE97-422220080E43}'] - regData = os.popen(r'reg.exe query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"').read().split('\r\n') - for i, line in enumerate(regData): - if line == "": continue - if i == 1: continue - line = line.split(' ') - if line[1] in musicKeys: - musicdata = Path(line[3]) - break - musicdata = checkPath(musicdata) + try: + musicKeys = ['My Music', '{4BD8D571-6D19-48D3-BE97-422220080E43}'] + regData = os.popen(r'reg.exe query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"').read().split('\r\n') + for i, line in enumerate(regData): + if line == "": continue + if i == 1: continue + line = line.split(' ') + if line[1] in musicKeys: + musicdata = Path(line[3]) + break + musicdata = checkPath(musicdata) + except Exception: + musicdata = "" if musicdata == "": musicdata = homedata / 'Music' musicdata = checkPath(musicdata)