mirror of
https://github.com/nims11/IPod-Shuffle-4g.git
synced 2025-12-08 00:18:01 +09:00
Skip hidden directories for auto playlists
This commit is contained in:
parent
6e919eca3d
commit
8dff7e8d5e
1 changed files with 16 additions and 14 deletions
30
shuffle.py
30
shuffle.py
|
|
@ -459,20 +459,22 @@ class Playlist(Record):
|
||||||
for (dirpath, dirnames, filenames) in os.walk(playlistpath):
|
for (dirpath, dirnames, filenames) in os.walk(playlistpath):
|
||||||
dirnames.sort()
|
dirnames.sort()
|
||||||
|
|
||||||
for filename in sorted(filenames, key = lambda x: x.lower()):
|
# Ignore any hidden directories
|
||||||
# Only add valid music files to playlist
|
if "/." not in dirpath.lower():
|
||||||
if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
|
for filename in sorted(filenames, key = lambda x: x.lower()):
|
||||||
# Reformat fullPath so that the basepath is lower/upper and the rest lower.
|
# Only add valid music files to playlist
|
||||||
# This is required to get the correct position (track index) inside Playlist.construct()
|
if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
|
||||||
# /media/username/USER'S IPOD/IPod_Control/Music/Artist/Album/Track.mp3
|
# Reformat fullPath so that the basepath is lower/upper and the rest lower.
|
||||||
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
# This is required to get the correct position (track index) inside Playlist.construct()
|
||||||
# /media/username/USER'S IPOD/
|
# /media/username/USER'S IPOD/IPod_Control/Music/Artist/Album/Track.mp3
|
||||||
basepath = self.base
|
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
||||||
# ipod_control/music/artist/album/track.mp3
|
# /media/username/USER'S IPOD/
|
||||||
ipodpath = self.path_to_ipod(fullPath)[1:].lower()
|
basepath = self.base
|
||||||
# /media/username/USER'S IPOD/ipod_control/music/artist/album/track.mp3
|
# ipod_control/music/artist/album/track.mp3
|
||||||
fullPath = os.path.abspath(os.path.join(basepath, ipodpath))
|
ipodpath = self.path_to_ipod(fullPath)[1:].lower()
|
||||||
listtracks.append(fullPath)
|
# /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:
|
if not recursive:
|
||||||
break
|
break
|
||||||
return listtracks
|
return listtracks
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue