Fixed no-eyeD3-without-ID3 bug.
/mp3togo/tags.py
blob:fb9a82b927146b769758894ad5fc4be2f3ffc41a -> blob:e1b524f0a48edd6aeb11003f2d2cd892c38a41d6
--- mp3togo/tags.py
+++ mp3togo/tags.py
@@ -94,7 +94,7 @@ class Tags(UserDict.DictMixin):
o['GENRE'] = 'Other'
return o
- if self._type == 'mp3' and HAVE_ID3:
+ if self._type == 'mp3':
rok = False
if HAVE_eyeD3:
eye = eyeD3.Tag()
@@ -112,10 +112,9 @@ class Tags(UserDict.DictMixin):
except eyeD3.tag.GenreException:
self._tags['GENRE'] = 'Other'
del eye
- rok = True
except eyeD3.tag.TagException:
pass
- if HAVE_ID3 and not rok:
+ elif HAVE_ID3:
info = ID3.ID3(self._file, as_tuple=1).as_dict()
self._tags = copytags(info)
del info
@@ -141,10 +140,15 @@ class Tags(UserDict.DictMixin):
path = path.replace('_', ' ')
for id, depth in [('ARTIST', -3), ('ALBUM', -2), ('TITLE', -1)]:
if not id in self._tags or self._tags[id][0] == '':
- try:
- self._tags[id] = [path.split(os.sep)[depth]]
- except IndexError:
- self._tags[id] = "%s unknown" % id.lower()
+ if self._opts['noguesstags']:
+ self._tags[id] = ['']
+ else:
+ try:
+ self._tags[id] = [path.split(os.sep)[depth]]
+ self._opts.log(1, "Missing %s tag, guessing %s from file name." %
+ (id, self._tags[id][0]))
+ except IndexError:
+ self._tags[id] = "%s unknown" % id.lower()
self._readok.set()
self._lock.release()