Commits

Anonymous committed 247276e

Made iTunes Library Searching work on Windows.

  • Participants
  • Parent commits e166cde

Comments (0)

Files changed (1)

app_sizer/app_import.py

     http://stackoverflow.com/questions/1962378/how-do-i-find-itunes-library-folder-on-mac-and-windows
     """
     paths = [
-            u"~/Music/iTunes/",
-            u"~/My Documents/My Music/iTunes/",
-            u"~/My Music/iTunes/",
+            u"Music/iTunes/",
+            u"My Documents/My Music/iTunes/",
+            u"My Music/iTunes/",
             ]
+    paths_tried = []
     for path in paths:
-        ep = os.path.expanduser(path)
-        if os.path.exists(ep):
-            return ep
-    raise IOError("Couldn't find any iTunes libraries in {}".format(paths))
+        for root in [os.environ[x] for x in ["HOME", "USERPROFILE"] if x in os.environ]:
+            ep = os.path.join(root, path)
+            paths_tried.append(ep)
+            if os.path.exists(ep):
+                return ep
+    raise IOError("Couldn't find any iTunes libraries in {}".format(paths_tried))
 
 def apps_path():
     "Find this system's iOS Apps folder in the iTunes library"