Crash for comments with a name but no value
Closed this issue · 3 comments
I ran into an issue where flac2all is crashing on some flac files where the comments have a name but no value. It looks like the issue in this case is a UFID tag that is missing a '=' sign (see comment 13 below). I'm assuming this is a badly tagged file, but flac2all should probably attempt to handle this rather than dump a stacktrace.
comments: 14
comment[0]: album=FAIRY TAIL ORIGINAL SOUND COLLECTION [Disc 1]
comment[1]: ALBUMARTIST=Yasuharu Takanashi
comment[2]: artist=Yasuharu Takanashi
comment[3]: date=2015
comment[4]: discnumber=1
comment[5]: Encoding Params=vers
comment[6]: genre=Soundtrack
comment[7]: iTunes_CDDB_IDs=22++
comment[8]: tempo=00000 BPM
comment[9]: title=FAIRY TAIL Main Theme 2014
comment[10]: DISCTOTAL=2
comment[11]: TRACKTOTAL=22
comment[12]: tracknumber=1
comment[13]: UFIDhttp://www.cddb.com/id3/taginfo1.html=3CD3N30Q524865463V5808B951FEAA8BFAD5602311A264C49335P1
Here's a stacktrace:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.8/dist-packages/flac2all-5.5-py3.8.egg/flac2all_pkg/flac2all_worker.py", line 44, in worker_process
sys.exit(eworker.run())
File "/usr/local/lib/python3.8/dist-packages/flac2all-5.5-py3.8.egg/flac2all_pkg/core.py", line 404, in run
raise(e)
File "/usr/local/lib/python3.8/dist-packages/flac2all-5.5-py3.8.egg/flac2all_pkg/core.py", line 394, in run
result = self.encode(infile, mode, opts)
File "/usr/local/lib/python3.8/dist-packages/flac2all-5.5-py3.8.egg/flac2all_pkg/core.py", line 317, in encode
return encf(infile, outfile)
File "/usr/local/lib/python3.8/dist-packages/flac2all-5.5-py3.8.egg/flac2all_pkg/mp3.py", line 83, in convert
inmetadata = flac().getflacmeta(infile)
File "/usr/local/lib/python3.8/dist-packages/flac2all-5.5-py3.8.egg/flac2all_pkg/flac.py", line 123, in getflacmeta
comment[1] = comment[1].strip()
IndexError: list index out of range
I threw a quick workaround in place so I could convert files (this is against the origin/version5 branch):
diff --git a/flac2all_pkg/flac.py b/flac2all_pkg/flac.py
index 1b0a805..66414dd 100644
--- a/flac2all_pkg/flac.py
+++ b/flac2all_pkg/flac.py
@@ -117,7 +117,10 @@ class flac(object):
# split according to [NAME]=[VALUE] structure
comment = data[1].split('=')
comment[0] = comment[0].strip()
- comment[1] = comment[1].strip()
+ if len(comment) > 1:
+ comment[1] = comment[1].strip()
+ else:
+ comment.append("")
# convert to upper case
# we want the key values to always be the same case, we decided on
Hello,
the FLAC spec defines the use of vorbis tags for its tagging system, which can be found here: https://xiph.org/vorbis/doc/v-comment.html
According to the spec, the format must consist of VARIABLE=VALUE, so whatever tagged your flac files has a bug in its tag writer.
Having flac2all break on bad input is not ideal, so I will most likely add logic to warn the user and continue.
A fix has been pushed to the version5 branch, please test and let me know if this is resolved.
Thanks!
Looks good, I just pulled the updated branch and rebuilt and it doesn't throw any errors.