benjamintanweihao / the-little-elixir-otp-guidebook-code

Code examples for The Little Elixir & OTP Guidebook
372 stars 71 forks source link

Listing 2.5 ID3Parser #6

Open rizafahmi opened 8 years ago

rizafahmi commented 8 years ago

Tried to run ID3Parser.parse "/Users/riza/Downloads/Barn_Owl-The_Long_Shadow.mp3". Got the following result:

Barn Owl^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ - The Long Shadow^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ (V^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@, 2013)

Music took from http://www.epitonic.com/#/genres/blues/.

Just wondering it's because of the mp3 file or the code. Because I tried 3 mp3s the results are similar.

ilasorsa commented 8 years ago

Hi @rizafahmi I solved that issue with

title  = String.trim title,  <<0>>
artist = String.trim artist, <<0>>
album  = String.trim album,  <<0>>

I think the problem is that we get all the 30 characters even if data are less than 30 so the rest are all 0s.

rizafahmi commented 8 years ago

@ilasorsa thanks! @benjamintanweihao should update his code on the book then :)

lothbrek commented 7 years ago

To be fair to @benjamintanweihao - I did not have this issue at all. Great solution @ilasorsa :+1:

wliment commented 7 years ago

the id3parse code in the book only could parse the ID3v1 info . but nowadays most of mp3 file id3 tag version is ID3v2 https://zh.wikipedia.org/wiki/ID3