digitalec / sonus

sonus is a cross-platform OverDrive audiobook client and chapterizer written in Python.
GNU General Public License v3.0
6 stars 1 forks source link

tag_data.get('TALB').text[0] --> 'NoneType' object has no attribute 'text' (Books without ID3 "Album") #10

Closed balthisar closed 3 months ago

balthisar commented 4 months ago

Sonus doesn't handle Overdrive audiobooks that are missing the ID3 TALB ("album") attribute:

  File "/Users/jderry/Development/sonus/sonus/chapterizer.py", line 153, in merge_chapter_parts
    title = tag_data.get('TALB').text[0]
            ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'text'

I'm not sure if this is related to #7 or not, but the error is the same. The workaround is to use sonus to download (only) the book, and then add the Album attribute with a tagger such as Kid3, and then point sonus at the downloaded files for chapterization.

As an alternative, you can modify your rlocal copy of chapterizer.py line 153 with the following:

            if title_raw := tag_data.get('TALB'):
                title = title_raw.text[0]
            else:
                title = 'Album Missing'

Sorry for not posting this as a PR, but this is a stopgap solution, and @digitalec might want to handle it somewhere in code or with a more Pythonesque style.

A book that demonstrates the failure mode is Wastelands by John Joseph Adams (editor), title number 1580350 on Overdrive.

digitalec commented 3 months ago

Thanks for the info. I haven't had much time to get around to fixing this relatively minor bug but it has been patched! Closing this as a duplicate of #7.