forked from upstream/IPod-Shuffle-4g
Fix for dealing with few latin-1 filenames
This commit is contained in:
parent
3813d17f9b
commit
b00008333d
1 changed files with 13 additions and 6 deletions
19
shuffle.py
19
shuffle.py
|
|
@ -246,7 +246,7 @@ class Track(Record):
|
||||||
text = " - ".join(audio.get("title", "") + audio.get("artist", ""))
|
text = " - ".join(audio.get("title", "") + audio.get("artist", ""))
|
||||||
|
|
||||||
# Handle the VoiceOverData
|
# Handle the VoiceOverData
|
||||||
self["dbid"] = hashlib.md5(text.encode("ascii", "ignore")).digest()[:8] #pylint: disable-msg=E1101
|
self["dbid"] = hashlib.md5(text.encode("latin-1", "ignore")).digest()[:8] #pylint: disable-msg=E1101
|
||||||
self.text_to_speech(text, self["dbid"])
|
self.text_to_speech(text, self["dbid"])
|
||||||
|
|
||||||
class PlaylistHeader(Record):
|
class PlaylistHeader(Record):
|
||||||
|
|
@ -350,7 +350,11 @@ class Playlist(Record):
|
||||||
base = os.path.dirname(os.path.abspath(filename))
|
base = os.path.dirname(os.path.abspath(filename))
|
||||||
if not os.path.exists(relative):
|
if not os.path.exists(relative):
|
||||||
relative = os.path.join(base, relative)
|
relative = os.path.join(base, relative)
|
||||||
return relative
|
fullPath = relative
|
||||||
|
ipodpath = self.parent.parent.parent.path
|
||||||
|
relPath = fullPath[fullPath.index(ipodpath)+len(ipodpath)+1:].lower()
|
||||||
|
fullPath = os.path.abspath(os.path.join(ipodpath, relPath))
|
||||||
|
return fullPath
|
||||||
|
|
||||||
def populate(self, filename):
|
def populate(self, filename):
|
||||||
f = open(filename, "rb")
|
f = open(filename, "rb")
|
||||||
|
|
@ -414,9 +418,9 @@ class Shuffler(object):
|
||||||
|
|
||||||
def determine_base(self, path):
|
def determine_base(self, path):
|
||||||
base = os.path.abspath(path)
|
base = os.path.abspath(path)
|
||||||
while not os.path.ismount(base):
|
# while not os.path.ismount(base):
|
||||||
base = os.path.dirname(base)
|
# base = os.path.dirname(base)
|
||||||
return path, base
|
return base, base
|
||||||
|
|
||||||
def populate(self):
|
def populate(self):
|
||||||
self.tunessd = TunesSD(self)
|
self.tunessd = TunesSD(self)
|
||||||
|
|
@ -425,8 +429,11 @@ class Shuffler(object):
|
||||||
# Ignore the speakable directory and any hidden directories
|
# Ignore the speakable directory and any hidden directories
|
||||||
if "ipod_control/speakable" not in dirpath.lower() and "/." not in dirpath.lower():
|
if "ipod_control/speakable" not in dirpath.lower() and "/." not in dirpath.lower():
|
||||||
for filename in sorted(filenames, key = lambda x: x.lower()):
|
for filename in sorted(filenames, key = lambda x: x.lower()):
|
||||||
|
fullPath = os.path.abspath(os.path.join(dirpath, filename))
|
||||||
|
relPath = fullPath[fullPath.index(self.path)+len(self.path)+1:].lower()
|
||||||
|
fullPath = os.path.abspath(os.path.join(self.path, relPath));
|
||||||
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"):
|
||||||
self.tracks.append(os.path.abspath(os.path.join(dirpath, filename)))
|
self.tracks.append(fullPath)
|
||||||
if os.path.splitext(filename)[1].lower() in (".pls", ".m3u"):
|
if os.path.splitext(filename)[1].lower() in (".pls", ".m3u"):
|
||||||
self.lists.append(os.path.abspath(os.path.join(dirpath, filename)))
|
self.lists.append(os.path.abspath(os.path.join(dirpath, filename)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue