mirror of
https://github.com/nims11/IPod-Shuffle-4g.git
synced 2025-12-08 00:18:01 +09:00
follow symlinks, avoid duplicates from following links
This commit is contained in:
parent
64414b6158
commit
fd6150c2db
1 changed files with 9 additions and 3 deletions
|
|
@ -510,6 +510,8 @@ class Playlist(Record):
|
||||||
# Only add valid music files to playlist
|
# Only add valid music files to playlist
|
||||||
if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
|
if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
|
||||||
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
||||||
|
if os.path.islink(fullPath):
|
||||||
|
fullPath = os.path.realpath(fullPath)
|
||||||
listtracks.append(fullPath)
|
listtracks.append(fullPath)
|
||||||
if not recursive:
|
if not recursive:
|
||||||
break
|
break
|
||||||
|
|
@ -617,14 +619,18 @@ class Shuffler(object):
|
||||||
# Ignore hidden files
|
# Ignore hidden files
|
||||||
if not filename.startswith("."):
|
if not filename.startswith("."):
|
||||||
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
||||||
|
if os.path.islink(fullPath):
|
||||||
|
fullPath = os.path.realpath(fullPath)
|
||||||
if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
|
if os.path.splitext(filename)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
|
||||||
|
if fullPath not in self.tracks:
|
||||||
self.tracks.append(fullPath)
|
self.tracks.append(fullPath)
|
||||||
if os.path.splitext(filename)[1].lower() in (".pls", ".m3u"):
|
if os.path.splitext(filename)[1].lower() in (".pls", ".m3u"):
|
||||||
|
if fullPath not in self.lists:
|
||||||
self.lists.append(fullPath)
|
self.lists.append(fullPath)
|
||||||
|
|
||||||
# Create automatic playlists in music directory.
|
# Create automatic playlists in music directory.
|
||||||
# Ignore the (music) root and any hidden directories.
|
# Ignore the (music) root and any hidden directories.
|
||||||
if self.auto_dir_playlists and "iPod_Control/Music/" in dirpath and "/." not in dirpath:
|
if self.auto_dir_playlists and ("iPod_Control/Music/" in dirpath or "iPod_Control/Podcasts/" 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.
|
# 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
|
depth = dirpath[len(self.path) + len(os.path.sep):].count(os.path.sep) - 1
|
||||||
if self.auto_dir_playlists < 0 or depth <= self.auto_dir_playlists:
|
if self.auto_dir_playlists < 0 or depth <= self.auto_dir_playlists:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue