Skip to content

Commit

Permalink
Add better handling of filenames and directories
Browse files Browse the repository at this point in the history
  • Loading branch information
nims11 committed Jun 7, 2016
1 parent f22fdee commit d3e5c76
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,16 @@ def populate(self):

# Create automatic playlists in music directory.
# Ignore the (music) root and any hidden directories.
if self.auto_playlists and "iPod_Control/Music/" in dirpath and "/." not in dirpath:
if self.auto_dir_playlists and "iPod_Control/Music/" in dirpath and "/." not in dirpath:
# Only go to a specific depth. -1 is unlimted, 0 is ignored as there is already a master playlist.
depth = dirpath[len(self.path) + len(os.path.sep):].count(os.path.sep) - 1
if self.auto_playlists < 0 or depth <= self.auto_playlists:
if self.auto_dir_playlists < 0 or depth <= self.auto_dir_playlists:
self.lists.append(os.path.abspath(dirpath))

if self.auto_id3_playlists != None:
for grouped_list in group_tracks_by_id3_template(self.tracks, self.auto_id3_playlists):
self.lists.append(grouped_list)

def write_database(self):
with open(os.path.join(self.path, "iPod_Control", "iTunes", "iTunesSD"), "wb") as f:
f.write(self.tunessd.construct())
Expand Down

0 comments on commit d3e5c76

Please sign in to comment.