-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Windows - 'My Music' folder won't be assumed to be on C drive #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Windows has a nice registry check to get the absolute path of the 'My Music' folder. This helps because some people change their location of their music folder.
spotdl/internals.py
Outdated
@@ -4,6 +4,10 @@ | |||
|
|||
from spotdl import const | |||
|
|||
try: | |||
from winreg import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No starred imports! Keep the namespace clean...
spotdl/internals.py
Outdated
# Explorer and Finder are actually in English on the file system. | ||
# So, defaulting to C:\Users\<user>\Music or /Users/<user>/Music | ||
# respectively is sufficient. | ||
# On Linux, default to /home/<user>/Music if the above method failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave all this in for future reference, at least put it before the final fallback return.
spotdl/internals.py
Outdated
try: | ||
key = OpenKey(HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0, KEY_ALL_ACCESS) | ||
return QueryValueEx(key, "My Music")[0] | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually no plain except
s ever, might be an exceptional case here. Still would be better to catch possible exceptions explicitly.
Let me know if there are anymore improvements 👍
spotdl/internals.py
Outdated
@@ -179,7 +179,7 @@ def get_unique_tracks(text_file): | |||
return lines | |||
|
|||
|
|||
# Get user's localized music directory | |||
# a hacky way to user's localized music directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
Was more thinking about leaving the reference to the original issue here than enforcing a note about the hacky way 😄
Looks good. Thanks! 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this very cool. Thanks @sillysam for doing this!
Windows has a nice registry check to get the absolute path of the 'My Music' folder. This helps because some people change their location of their music folder.