Skip to content
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

Windows - 'My Music' folder won't be assumed to be on C drive #387

Merged
merged 3 commits into from
Oct 9, 2018
Merged

Windows - 'My Music' folder won't be assumed to be on C drive #387

merged 3 commits into from
Oct 9, 2018

Conversation

ctrlsam
Copy link
Contributor

@ctrlsam ctrlsam commented Oct 5, 2018

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.

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.
@@ -4,6 +4,10 @@

from spotdl import const

try:
from winreg import *
Copy link
Contributor

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 Show resolved Hide resolved
# 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.
Copy link
Contributor

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.

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually no plain excepts 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 Show resolved Hide resolved
@@ -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
Copy link
Contributor

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 😄

@linusg
Copy link
Contributor

linusg commented Oct 6, 2018

Looks good. Thanks! 😃

@linusg linusg requested a review from ritiek October 8, 2018 12:39
Copy link
Member

@ritiek ritiek left a 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!

@ritiek ritiek merged commit 71ee6ad into spotDL:master Oct 9, 2018
@ritiek ritiek added this to the v1.1.0 milestone Nov 13, 2018
@ritiek ritiek mentioned this pull request Nov 13, 2018
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants