From 8dff7e8d5e15521e41a02b91d346f81e2b30441d Mon Sep 17 00:00:00 2001 From: NicoHood Date: Tue, 5 Apr 2016 22:03:10 +0200 Subject: [PATCH] Skip hidden directories for auto playlists --- shuffle.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/shuffle.py b/shuffle.py index 4e95d43..acb347c 100755 --- a/shuffle.py +++ b/shuffle.py @@ -459,20 +459,22 @@ class Playlist(Record): for (dirpath, dirnames, filenames) in os.walk(playlistpath): dirnames.sort() - for filename in sorted(filenames, key = lambda x: x.lower()): - # Only add valid music files to playlist - if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"): - # Reformat fullPath so that the basepath is lower/upper and the rest lower. - # This is required to get the correct position (track index) inside Playlist.construct() - # /media/username/USER'S IPOD/IPod_Control/Music/Artist/Album/Track.mp3 - fullPath = os.path.abspath(os.path.join(dirpath, filename)) - # /media/username/USER'S IPOD/ - basepath = self.base - # ipod_control/music/artist/album/track.mp3 - ipodpath = self.path_to_ipod(fullPath)[1:].lower() - # /media/username/USER'S IPOD/ipod_control/music/artist/album/track.mp3 - fullPath = os.path.abspath(os.path.join(basepath, ipodpath)) - listtracks.append(fullPath) + # Ignore any hidden directories + if "/." not in dirpath.lower(): + for filename in sorted(filenames, key = lambda x: x.lower()): + # Only add valid music files to playlist + if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"): + # Reformat fullPath so that the basepath is lower/upper and the rest lower. + # This is required to get the correct position (track index) inside Playlist.construct() + # /media/username/USER'S IPOD/IPod_Control/Music/Artist/Album/Track.mp3 + fullPath = os.path.abspath(os.path.join(dirpath, filename)) + # /media/username/USER'S IPOD/ + basepath = self.base + # ipod_control/music/artist/album/track.mp3 + ipodpath = self.path_to_ipod(fullPath)[1:].lower() + # /media/username/USER'S IPOD/ipod_control/music/artist/album/track.mp3 + fullPath = os.path.abspath(os.path.join(basepath, ipodpath)) + listtracks.append(fullPath) if not recursive: break return listtracks