magicgoose / simple_dr_meter

An (optimized) implementation of the music DR measurement (compliant with http://dr.loudness-war.info/), it supports CUE sheets and is faster than all currently available alternatives (at the time of writing, not sure about now)
GNU General Public License v3.0
20 stars 3 forks source link

Does not handle files with empty tags #10

Open dakeryas opened 1 year ago

dakeryas commented 1 year ago

The get_group_title function fails when the performers or albums are empty.

writing log to /Users/me/Downloads/dr.txt
Traceback (most recent call last):
  File "/Users/me/Software/simple_dr_meter/./main.py", line 268, in <module>
    main()
  File "/Users/me/Software/simple_dr_meter/./main.py", line 145, in main
    write_log(f.write, dr_log_items, dr_mean)
  File "/Users/me/Software/simple_dr_meter/./main.py", line 54, in write_log
    group_name = get_group_title(group)
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/Software/simple_dr_meter/./main.py", line 35, in get_group_title
    return f'{", ".join(group.performers)} — {", ".join(group.albums)}'
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, NoneType found

Perhaps a patch like the following one would be good enough:

 def get_group_title(group: LogGroup):
-    return f'{", ".join(group.performers)} — {", ".join(group.albums)}'
+    if not (group.performers is None or group.albums is None):
+        return f'{", ".join(group.performers)} — {", ".join(group.albums)}'
+    return ""