diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-05-15 14:10:24 +0200 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-05-15 14:10:24 +0200 |
commit | d175a47b966c2c2d1569626a7699e1ff1a5bf36b (patch) | |
tree | c246c8bd64faa1eb1f20e630a84270f4bf1fdfc8 /nephilim/song.py | |
parent | 444f7802b93927e29ee8b7073c6472d0558e5063 (diff) |
song: correctly handle garbage track numbers.
Diffstat (limited to 'nephilim/song.py')
-rw-r--r-- | nephilim/song.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/nephilim/song.py b/nephilim/song.py index d2221ec..8f672ba 100644 --- a/nephilim/song.py +++ b/nephilim/song.py @@ -30,16 +30,10 @@ class Song: if 'id' in self._data: self._data['id'] = int(self._data['id']) if 'track' in self._data: - # make sure the track is a valid number! - t=self._data['track'] - for i in xrange(len(t)): - if ord(t[i])<ord('0') or ord(t[i])>ord('9'): - try: - self._data['track']=int(t[0:i]) - except TypeError: - self._data['track']=-1 - break - self._data['track']=int(self._data['track']) + try: + self._data['track'] = int(self._data['track']) + except ValueError: + self._data['track'] = 0 # ensure all string-values are utf-8 encoded for tag in self._data.keys(): |