TypeError: coercing to Unicode: need string or buffer, NoneType found

Bug #714120 reported by dRewsus
38
This bug affects 6 people
Affects Status Importance Assigned to Milestone
CoverLovin
Fix Released
Critical
James Stewart

Bug Description

OS: Ubuntu 10.10

Just tried on a small sample of music.

./coverlovin.py "/home/drewsus/Downloads/Music"
Evaluating /home/drewsus/Downloads/Music/2000 - Parachutes
Album info found in 01 Don't Panic.mp3: Coldplay - Parachutes
Trying url: http://www.di-arezzo.co.uk/multimedia/images/wise/couv/am970893.jpg
Downloading cover from: http://www.di-arezzo.co.uk/multimedia/images/wise/couv/am970893.jpg
 to:/home/drewsus/Downloads/Music/2000 - Parachutes/cover.jpg
Evaluating /home/drewsus/Downloads/Music/Elvis As Recorded At Madison Square Garden
Evaluating /home/drewsus/Downloads/Music/Filthy Dubstep
Traceback (most recent call last):
  File "./coverlovin.py", line 220, in <module>
    sys.exit(main())
  File "./coverlovin.py", line 217, in main
    process_dir(argsOpts['musicDir'])
  File "./coverlovin.py", line 125, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 144, in process_dir
    log.info("Album info found in " + file + ": " + artist + " - " + album)
TypeError: coercing to Unicode: need string or buffer, NoneType found

Revision history for this message
dRewsus (drewsus) wrote :

here is another:
./coverlovin.py "/home/drewsus/Downloads/Music" -i jpg -n "cover.jpg"Evaluating /home/drewsus/Downloads/Music/2000 - Parachutes
Album info found in 01 Don't Panic.mp3: Coldplay - Parachutes
Trying url: http://www.di-arezzo.co.uk/multimedia/images/wise/couv/am970893.jpg
Downloading cover from: http://www.di-arezzo.co.uk/multimedia/images/wise/couv/am970893.jpg
 to:/home/drewsus/Downloads/Music/2000 - Parachutes/cover.jpg
Evaluating /home/drewsus/Downloads/Music/Elvis As Recorded At Madison Square Garden
Evaluating /home/drewsus/Downloads/Music/Ronald Jenkees - Disorganized Fun (2009)
Traceback (most recent call last):
  File "./coverlovin.py", line 220, in <module>
    sys.exit(main())
  File "./coverlovin.py", line 217, in main
    process_dir(argsOpts['musicDir'])
  File "./coverlovin.py", line 125, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 139, in process_dir
    id3r = id3reader.Reader(fileFullPath)
  File "/home/drewsus/Programs/coverlovin_1.0/id3reader.py", line 215, in __init__
    self._readId3()
  File "/home/drewsus/Programs/coverlovin_1.0/id3reader.py", line 343, in _readId3
    frame._interpret()
  File "/home/drewsus/Programs/coverlovin_1.0/id3reader.py", line 142, in _interpret
    value = self.rawData[1:].decode(_encodings[encoding])
  File "/usr/lib/python2.6/encodings/utf_16.py", line 16, in decode
    return codecs.utf_16_decode(input, errors, True)
UnicodeDecodeError: 'utf16' codec can't decode byte 0x54 in position 30: truncated data

Revision history for this message
Jorge E. Gómez (jorgeegomez) wrote :

I get a slightly different error, but it seems to be part of the same trend:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 29: ordinal not in range(128)

The only non-ascii file in the dir was:
An Pierlé - Are 'Friends' Electric.mp3

Revision history for this message
Fabio Lambertini (fabio-lambe) wrote :

I found same problem with typical italian accented letters like à,ò,ù,è,ì.
Error was the same "UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 29: ordinal not in range(128)"

Revision history for this message
James Stewart (amorphic) wrote :

Hi guys,

Thanks for trying out CoverLovin and sending the helpful bug reports. I've isolated the problem and will hopefully have an update ready for testing in the next day or so.

Cheers,

James

Changed in coverlovin:
status: New → In Progress
importance: Undecided → Critical
assignee: nobody → James Stewart (jstewart101)
James Stewart (amorphic)
Changed in coverlovin:
milestone: none → 1.01
Revision history for this message
James Stewart (amorphic) wrote :

Hi guys,

I've done some work on the utf-8 problem. Could you try running the attached version against your music libraries and see how it goes?

Thanks,

James

Revision history for this message
Donal (donaljoconnor) wrote :

Hi James,

Just tried the update and i'm still seeing the same issue.

Evaluating /home/donal/superfly/music/Arthur Lee & Love/Forever Changes
Traceback (most recent call last):
  File "./coverlovin.py", line 221, in <module>
    sys.exit(main())
  File "./coverlovin.py", line 218, in main
    process_dir(unicode(argsOpts['musicDir'], 'utf-8'))
  File "./coverlovin.py", line 126, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 126, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 145, in process_dir
    log.info("Album info found in " + file + ": " + artist + " - " + album)
TypeError: coercing to Unicode: need string or buffer, NoneType found

Revision history for this message
Donal (donaljoconnor) wrote :

Hi James,

I can send you the folder in question if you like?

Let me know what you think.

Thanks,

Donal

Revision history for this message
James Stewart (amorphic) wrote :

Ah, it seems that this bug raised in #714189 was a separate issue to #714120 after all. I saw the Unicode error message and assumed that it was the same problem.

I think the problem you are seeing might be caused by files with the artist tag set but not the album tag or vice versa.

Donal can you try the attached version and see if it work correctly?

Thanks,

James

Revision history for this message
Donal (donaljoconnor) wrote :

That issue is fixed now. However I'm getting another error now.

Album info found in 03 - Azymuth - Carambola (Roc Hunter Mix).mp3: Deep Dish - Yoshiesque Two (Westcoast)
Traceback (most recent call last):
  File "./coverlovin.py", line 225, in <module>
    sys.exit(main())
  File "./coverlovin.py", line 222, in main
    process_dir(unicode(argsOpts['musicDir'], 'utf-8'))
  File "./coverlovin.py", line 126, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 126, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 150, in process_dir
    coverUrls = get_img_urls([artist, album])
  File "./coverlovin.py", line 101, in get_img_urls
    results = simplejson.load(response)
  File "/usr/lib/pymodules/python2.6/simplejson/__init__.py", line 328, in load
    use_decimal=use_decimal, **kw)
  File "/usr/lib/pymodules/python2.6/simplejson/__init__.py", line 384, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/pymodules/python2.6/simplejson/decoder.py", line 402, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/pymodules/python2.6/simplejson/decoder.py", line 420, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

Revision history for this message
Fabio Lambertini (fabio-lambe) wrote :

That fix the issue for me. I just scanned all my music library without an error...

Revision history for this message
dRewsus (drewsus) wrote :

I just scanned my 500 artist/16,000 song collection and it worked wonderfully this time. There were some artists' album covers that were not downloaded, but those issues could be out of your hands. Seemed more like 404/403 errors.

Revision history for this message
dRewsus (drewsus) wrote :

I should not that "this time" used your attachment from comment #9

Revision history for this message
James Stewart (amorphic) wrote :

Hi guys, thanks again for taking the time to test this for me.

I have found and fixed another bug in the way that I was processing multi-word album titles and artist names.

Donal I think this will fix your problem and dRewsus this *should* be more successful at finding results, so it will hopefully find covers for those albums the last version missed. Fabio - if the last version missed any albums for you, this version should get covers for them correctly.

If you could give this version a go and let me know how it works for you that'd be great.

Cheers,

James

Revision history for this message
Donal (donaljoconnor) wrote :

Hi James,

That issue is fixed. I'm seeing a different one now.

Evaluating /home/donal/superfly/music/Frazier Chorus/Sue
/home/donal/superfly/music/Frazier Chorus/Sue: cover.jpg exists and overwrite is disabled - skipping
Evaluating /home/donal/superfly/music/Frazier Chorus
Evaluating /home/donal/superfly/music/Free/The Best Of
Traceback (most recent call last):
  File "./coverlovin.py", line 238, in <module>
    sys.exit(main())
  File "./coverlovin.py", line 235, in main
    process_dir(unicode(argsOpts['musicDir'], 'utf-8'))
  File "./coverlovin.py", line 139, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 139, in process_dir
    process_dir(dir)
  File "./coverlovin.py", line 153, in process_dir
    id3r = id3reader.Reader(fileFullPath)
  File "/home/donal/Dropbox/coverlovin_1.0/id3reader.py", line 215, in __init__
    self._readId3()
  File "/home/donal/Dropbox/coverlovin_1.0/id3reader.py", line 343, in _readId3
    frame._interpret()
  File "/home/donal/Dropbox/coverlovin_1.0/id3reader.py", line 142, in _interpret
    value = self.rawData[1:].decode(_encodings[encoding])
  File "/usr/lib/python2.6/encodings/utf_16.py", line 16, in decode
    return codecs.utf_16_decode(input, errors, True)
UnicodeDecodeError: 'utf16' codec can't decode byte 0x54 in position 10: truncated data

Revision history for this message
James Stewart (amorphic) wrote :

Donal,

That error is actually coming from the id3reader.py module. It seems to have a problem with one of the files in /home/donal/superfly/music/Free/The Best Of, (probably the first mp3 file in the directory).

Could you take a look and see if there is anything unusual about the filename or the id3tags of the first mp3 file in that directory? Please feel free to send me a copy of the file for testing.

In the mean time I'm going to close this bug off. If I can find a separate problem with my code I'll raise a new bug.

Thanks again for your help,

James

Changed in coverlovin:
status: In Progress → Fix Committed
James Stewart (amorphic)
Changed in coverlovin:
status: Fix Committed → Fix Released
Revision history for this message
Donal (donaljoconnor) wrote :

Thanks James. There were some dodgy ID3 tags.

Thanks for a great script!

Revision history for this message
Fabio Lambertini (fabio-lambe) wrote :

That new version work again with no problem for me.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.