ptrstn / dailyblink

Downloads the Audio and Text of the Free Daily book from Blinkist.com
MIT License
43 stars 6 forks source link

Failed to set m4a tags today #9

Closed NicoWeio closed 3 years ago

NicoWeio commented 3 years ago

For so far unknown reasons, this program could not set tags on today's (2021-05-15) German free blink, Meisterkurs Rhetorik - Benedikt Held.

Traceback (most recent call last):
  File "/home/nicolai/Daten/Programmieren/1 GitHub-Forks/dailyblink/dailyblink/blinks.py", line 207, in <module>
    main()
  File "/home/nicolai/Daten/Programmieren/1 GitHub-Forks/dailyblink/dailyblink/blinks.py", line 189, in main
    set_m4a_meta_data(
  File "/home/nicolai/Daten/Programmieren/1 GitHub-Forks/dailyblink/dailyblink/blinks.py", line 130, in set_m4a_meta_data
    tags["\xa9ART"] = artist
TypeError: 'NoneType' object does not support item assignment

I fixed it by adding

if not tags:
    print("WARN: Cannot apply tags to m4a!")
    return

to set_m4a_meta_data.

I will keep an eye on this…

ManuelSchneid3r commented 3 years ago

@NicoWeio hat der Download für dich noch funktioniert am Ende? Könntest du mir den Blink schicken falls ja?

ManuelSchneid3r commented 3 years ago

Bei "Kreativität - Melanie Raabe", und "Der Mensch und seine Symbole - Carl Gustav Jung" scheint das selbe passiert zu sein.

NicoWeio commented 3 years ago

Bei "Kreativität - Melanie Raabe", und "Der Mensch und seine Symbole - Carl Gustav Jung" scheint das selbe passiert zu sein.

Bei mir ebenso. War mir noch gar nicht aufgefallen. For reference: 07.05.21 und 14.05.21 sind die anderen betroffenen Daten.

Ich kann dir die mit meinem Fix heruntergeladenen Blinks gerne schicken, aber sehe bei dir keine E-Mail-Adresse oder dergleichen.


PS: Du bist „führender Entwickler“ von Albert? Ist ja cool, Albert habe ich eine Zeit lang gerne benutzt. :)

ManuelSchneid3r commented 3 years ago

PS: Du bist „führender Entwickler“ von Albert? Ist ja cool, Albert habe ich eine Zeit lang gerne benutzt. :)

ja, freut mich immer zu hören.

das problem ist hiermit https://github.com/ptrstn/dailyblink/pull/11 gefixt

ptrstn commented 3 years ago

Thanks for reporting this issue.

I just checked the examples you mentioned and noticed the problems which you already found out about yourself. The books you mentioned were the following:

After examining the media files that are freely available with this book through the linked web pages I realized that at least one of these blinks use a different file format:

As can be seen the second file (Kreativität by Melanie Raabe) gets renamed from .m4a to .mp4 when trying to save it via google chrome. This could cause another issue.

In comparison, earlier books like the todays free dailys can be contemplated:

>>> from mutagen.mp4 import MP4

>>> MP4("rhetorik.m4a").tags is None
True

>>> MP4("kreativ.mp4").tags is None
True

>>> MP4("symbole.m4a").tags is None
False

>>> MP4("symbole.m4a").tags
{'©too': ['Lavf58.28.101']}

>>> MP4("bergauf.m4a").tags is None
False

>>> MP4("bergauf.m4a").tags
{'©nam': ['0'], '©too': ['Lavf58.28.101'], 'pgap': False, 'cpil': False}

>>> MP4("art.m4a").tags is None
False

>>> MP4("art.m4a").tags
{'©too': ['Lavf58.28.101']}

So at least a few of them do indeed have no MP4Tags element.

from dailyblink.blinks import set_m4a_meta_data
set_m4a_meta_data("rhetorik.m4a")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/***/***/***/dailyblink/dailyblink/blinks.py", line 139, in set_m4a_meta_data
    tags.save(filename)
AttributeError: 'NoneType' object has no attribute 'save'

-> No MP4Tags element

set_m4a_meta_data("kreativ.mp4", "Melanie Raabe")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/***/***/***/dailyblink/dailyblink/blinks.py", line 130, in set_m4a_meta_data
    tags["\xa9ART"] = artist
TypeError: 'NoneType' object does not support item assignment

-> No MP4Tags element

set_m4a_meta_data("symbole.m4a", "Carl Gustav Jung")
MP4("symbole.m4a").tags
{'©ART': ['Carl Gustav Jung'], '©too': ['Lavf58.28.101']}

-> All fine

So, as @ManuelSchneid3r mentioned, the MP4Tags have to be added to the file when not already present.

See: add_tags