From dfc062180bdeeba2505f45d6b65b5a5578f55e80 Mon Sep 17 00:00:00 2001 From: spl0k Date: Sat, 26 Oct 2013 13:13:19 +0200 Subject: [PATCH] Fix for files without tag Closes #6 --- api/browse.py | 2 +- scanner.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/browse.py b/api/browse.py index e9b7831..df1b691 100755 --- a/api/browse.py +++ b/api/browse.py @@ -104,7 +104,7 @@ def list_artists(): # According to the API page, there are no parameters? indexes = {} for artist in Artist.query.all(): - index = artist.name[0].upper() + index = artist.name[0].upper() if artist.name else '?' if index in map(str, xrange(10)): index = '#' elif index not in string.letters: diff --git a/scanner.py b/scanner.py index 907c1de..304d1a5 100755 --- a/scanner.py +++ b/scanner.py @@ -70,11 +70,11 @@ class Scanner: tr.disc = self.__try_read_tag(tag, 'discnumber', 1, lambda x: int(x[0].split('/')[0])) tr.number = self.__try_read_tag(tag, 'tracknumber', 1, lambda x: int(x[0].split('/')[0])) - tr.title = self.__try_read_tag(tag, 'title') + tr.title = self.__try_read_tag(tag, 'title', '') tr.year = self.__try_read_tag(tag, 'date', None, lambda x: int(x[0].split('-')[0])) tr.genre = self.__try_read_tag(tag, 'genre') tr.duration = int(tag.info.length) - tr.album = self.__find_album(self.__try_read_tag(tag, 'artist'), self.__try_read_tag(tag, 'album')) + tr.album = self.__find_album(self.__try_read_tag(tag, 'artist', ''), self.__try_read_tag(tag, 'album', '')) tr.bitrate = (tag.info.bitrate if hasattr(tag.info, 'bitrate') else int(os.path.getsize(path) * 8 / tag.info.length)) / 1000 tr.content_type = get_mime(os.path.splitext(path)[1][1:]) tr.last_modification = os.path.getmtime(path)