Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in fetchart #1805

Closed
Phyks opened this issue Jan 10, 2016 · 8 comments
Closed

TypeError in fetchart #1805

Phyks opened this issue Jan 10, 2016 · 8 comments
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."

Comments

@Phyks
Copy link

Phyks commented Jan 10, 2016

Hi,

I got errors and a traceback with the fetchart plugin. Traceback is:

Alanis Morissette/MTV Unplugged (12 items)
Tagging:
    Alanis Morissette - MTV Unplugged
URL:
    http:https://musicbrainz.org/release/a4a547a5-b884-4642-b33b-138682278cb1
(Similarity: 100.0%) (CD, 1999, DE, Maverick, European release)
Traceback (most recent call last):
  File "/home/b6/.local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.16', 'console_scripts', 'beet')()
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1207, in main
    _raw_main(args)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1197, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 947, in import_func
    import_files(lib, paths, query)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 924, in import_files
    session.run()
  File "/home/b6/.local/lib/python2.7/site-packages/beets/importer.py", line 318, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 302, in run
    out = self.coro.send(msg)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 184, in coro
    func(*(args + (task,)))
  File "/home/b6/.local/lib/python2.7/site-packages/beets/importer.py", line 1358, in plugin_stage
    func(session, task)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 430, in fetch_art
    path = self.art_for_album(task.album, task.paths, local)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 565, in art_for_album
    for url in self._source_urls(album):
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 618, in _source_urls
    for url in urls:
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 304, in get
    headers={'content-type': 'application/json'},
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 93, in request
    return _logged_get(self._log, *args, **kwargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 80, in _logged_get
    return s.send(prepped, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 595, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 189, in resolve_redirects
    allow_redirects=False,
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 308, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 826, in send
    self.sock.sendall(data)
  File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 208, in sendall
    return self.connection.sendall(data)
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 969, in sendall
    raise TypeError("buf must be a byte string")
TypeError: buf must be a byte string

Undoing this commit fixes it partly (no longer this error anymore, but some other errors appear, although I managed to get it running).

cc @Niols which is having this issue as well

Thanks!

@Niols
Copy link

Niols commented Jan 10, 2016

I confirm, reverting a502610 for beetsplug/fetchart.py solves this problem.

It creates an other one (for less files though):

/home/b6/music/upload/_BAD_UTF8/Manu Katché/Neighbourhood (10 items)
Tagging:
    Manu Katché - Neighbourhood
URL:
    http:https://musicbrainz.org/release/745d78dc-7227-4ad8-854e-d529303b764c
(Similarity: 100.0%) (CD, 2005, DE, ECM)
Traceback (most recent call last):
  File "/home/b6/.local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.16', 'console_scripts', 'beet')()
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1207, in main
    _raw_main(args)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1197, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 947, in import_func
    import_files(lib, paths, query)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 924, in import_files
    session.run()
  File "/home/b6/.local/lib/python2.7/site-packages/beets/importer.py", line 318, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 302, in run
    out = self.coro.send(msg)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 184, in coro
    func(*(args + (task,)))
  File "/home/b6/.local/lib/python2.7/site-packages/beets/importer.py", line 1358, in plugin_stage
    func(session, task)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 429, in fetch_art
    path = self.art_for_album(task.album, task.paths, local)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 564, in art_for_album
    for url in self._source_urls(album):
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 617, in _source_urls
    for url in urls:
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 231, in get
    artist=album.albumartist.title(), album=album.album)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 10: ordinal not in range(128)

@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label Jan 10, 2016
@sampsyo
Copy link
Member

sampsyo commented Jan 10, 2016

Thanks! This does look like a bug, but some more information would be really helpful. Can you get a verbose log for a specific file that triggers the problem?

Doing this with a beet fetchart command as opposed to an import might be easier.

@Niols
Copy link

Niols commented Jan 10, 2016

Here is the output of beet fetchart Alanis:

fetchart: Alanis Morissette - Jagged Little Pill: found album art
Traceback (most recent call last):
  File "/home/b6/.local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.16', 'console_scripts', 'beet')()
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1207, in main
    _raw_main(args)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1197, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 457, in func
    self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 593, in batch_fetch_art
    path = self.art_for_album(album, local_paths)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 565, in art_for_album
    for url in self._source_urls(album):
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 618, in _source_urls
    for url in urls:
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 304, in get
    headers={'content-type': 'application/json'},
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 93, in request
    return _logged_get(self._log, *args, **kwargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 80, in _logged_get
    return s.send(prepped, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 595, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 189, in resolve_redirects
    allow_redirects=False,
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 308, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 826, in send
    self.sock.sendall(data)
  File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 208, in sendall
    return self.connection.sendall(data)
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 969, in sendall
    raise TypeError("buf must be a byte string")
TypeError: buf must be a byte string

beet fails on 1999 - MTV Unplugged

I'm not sure that that brings much more information.

This seems to be coming from the unicode_literals import in beetsplug/fetchart.py (here)
That's also what seems to be saying the fourth comment of this issue.

I stay available for more questions

@Niols
Copy link

Niols commented Jan 10, 2016

For the problem created by the deleting of unicode literals, it seems to be coming from this line: https://github.com/beetbox/beets/blob/master/beetsplug/fetchart.py#L268 where both parameters need to be encoded to utf8.
It's working on some examples, I'll do some testing and report back.

@untitaker
Copy link
Contributor

Do not use unicode_literals, it causes problems with the stdlib in Python 2.

It's been a major pain point in any project I've ever worked on. See PythonCharmers/python-future#22

@sampsyo
Copy link
Member

sampsyo commented Jan 11, 2016

That helps; thanks! If I can ask for one more favor, can you also get the verbose output? That is, beet -vv fetchart ....

@untitaker: Yes, turning off unicode_literals altogether might be a good idea separately. It has been mostly a headache. In this particular case, though, we just need to figure out which parameter has to be encoded before passing to requests.

@Niols
Copy link

Niols commented Jan 11, 2016

Here is the corrected version without unicode_literals and with the correct encodings in the line 268:

b6@funf:~$ beet -vv fetchart Alanis
user configuration: /home/b6/.config/beets/config.yaml
data directory: /home/b6/.config/beets
plugin paths: 
Sending event: pluginload
artresizer: method is (2, (6, 8, 9))
inline: adding item field multidisc
library database: /home/b6/music/library/good.blb
library directory: /home/b6/music/library/good
Sending event: library_opened
fetchart: trying source coverart for album Alanis Morissette - Jagged Little Pill
fetchart: downloading image: http:https://coverartarchive.org/release/0838ba20-a571-4b3c-8c0c-a31436d373b3/front
fetchart: downloaded art to: /tmp/tmpvSUGqB.jpg
fetchart: image size: (1425, 1425)
fetchart: image needs resizing (1425 > 500)
fetchart: using remote image /tmp/tmpvSUGqB.jpg
artresizer: ImageMagick resizing /tmp/tmpvSUGqB.jpg to /tmp/tmpU0Vc83.jpg
Sending event: art_set
embedart: Resizing album art to 500 pixels wide
artresizer: ImageMagick resizing /home/b6/music/library/good/Alanis Morissette/1995 - Jagged Little Pill/cover.jpg to /tmp/tmpWN78H2.jpg
embedart: Embedding album art into Alanis Morissette - Jagged Little Pill
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - All I Really Want to: /tmp/tmpSVi_Oa.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - You Oughta Know to: /tmp/tmplqN1N2.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Perfect to: /tmp/tmpp1hRTZ.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - You Learn to: /tmp/tmpyydlJY.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Head Over Feet to: /tmp/tmpdJKOcU.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Ironic to: /tmp/tmpSTLood.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Not the Doctor to: /tmp/tmpAyaR85.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Wake Up to: /tmp/tmpLt_YJX.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - You Oughta Know (Jimmy the Saint Blend) / Your House to: /tmp/tmpEVUsZw.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Removing album art file for Alanis Morissette - Jagged Little Pill
Sending event: database_change
Sending event: database_change
fetchart: Alanis Morissette - Jagged Little Pill: found album art
fetchart: trying source coverart for album Alanis Morissette - MTV Unplugged
fetchart: downloading image: http:https://coverartarchive.org/release/a4a547a5-b884-4642-b33b-138682278cb1/front
fetchart: downloaded art to: /tmp/tmpsVO65a.jpg
fetchart: image size: (1410, 1395)
fetchart: image is not square (1410 != 1395)
fetchart: downloading image: http:https://coverartarchive.org/release-group/1f57afa7-4a14-37b4-a196-572738fa5ebb/front
fetchart: downloaded art to: /tmp/tmpsNQ5Bk.jpg
fetchart: image size: (1410, 1395)
fetchart: image is not square (1410 != 1395)
fetchart: trying source albumart for album Alanis Morissette - MTV Unplugged
fetchart: getting URL: http:https://www.albumart.org/index_detail.php?asin=B00002MZ12
fetchart: scraped art URL: http:https://www.albumart.org/index_detail.php?asin=B00002MZ12
fetchart: no image found on page
fetchart: trying source amazon for album Alanis Morissette - MTV Unplugged
fetchart: downloading image: http:https://images.amazon.com/images/P/B00002MZ12.01.LZZZZZZZ.jpg
fetchart: downloaded art to: /tmp/tmpShcGAo.jpg
fetchart: image size: (500, 494)
fetchart: image is not square (500 != 494)
fetchart: trying source wikipedia for album Alanis Morissette - MTV Unplugged
fetchart: getting URL: http:https://dbpedia.org/sparql?query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0A+++++++++++++++++PREFIX+dbpprop%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0A+++++++++++++++++PREFIX+owl%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0A+++++++++++++++++PREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A+++++++++++++++++PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0A%0A+++++++++++++++++SELECT+DISTINCT+%3FpageId+%3FcoverFilename+WHERE+%7B%0A+++++++++++++++++++%3Fsubject+owl%3AwikiPageID+%3FpageId+.%0A+++++++++++++++++++%3Fsubject+dbpprop%3Aname+%3Fname+.%0A+++++++++++++++++++%3Fsubject+rdfs%3Alabel+%3Flabel+.%0A+++++++++++++++++++%7B+%3Fsubject+dbpprop%3Aartist+%3Fartist+%7D%0A+++++++++++++++++++++UNION%0A+++++++++++++++++++%7B+%3Fsubject+owl%3Aartist+%3Fartist+%7D%0A+++++++++++++++++++%7B+%3Fartist+foaf%3Aname+%22Alanis+Morissette%22%40en+%7D%0A+++++++++++++++++++++UNION%0A+++++++++++++++++++%7B+%3Fartist+dbpprop%3Aname+%22Alanis+Morissette%22%40en+%7D%0A+++++++++++++++++++%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2FAlbum%3E+.%0A+++++++++++++++++++%3Fsubject+dbpprop%3Acover+%3FcoverFilename+.%0A+++++++++++++++++++FILTER+%28+regex%28%3Fname%2C+%22MTV+Unplugged%22%2C+%22i%22%29+%29%0A++++++++++++++++++%7D%0A+++++++++++++++++Limit+1&timeout=2500&format=application%2Fsparql-results%2Bjson  
fetchart: getting URL: http:https://en.wikipedia.org/w/api.php?titles=File%3AAlanis+Unplugged+album+cover.jpg&format=json&prop=imageinfo&continue=&action=query&iiprop=url  
fetchart: downloading image: https://upload.wikimedia.org/wikipedia/en/6/6d/Alanis_Unplugged_album_cover.jpg  
fetchart: downloaded art to: /tmp/tmp5bkNXr.jpg  
fetchart: image size: (300, 300)
fetchart: using remote image /tmp/tmp5bkNXr.jpg
Sending event: art_set
embedart: Resizing album art to 500 pixels wide
artresizer: ImageMagick resizing /home/b6/music/library/good/Alanis Morissette/1999 - MTV Unplugged/cover.jpg to /tmp/tmpIlneuN.jpg
embedart: Embedding album art into Alanis Morissette - MTV Unplugged
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - You Learn to: /tmp/tmpVPUWdr.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - Joining You to: /tmp/tmpZFhnQ0.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - No Pressure Over Cappuccino to: /tmp/tmpFdwJPs.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - That I Would Be Good to: /tmp/tmpcPIvG0.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - Head Over Feet to: /tmp/tmpxeJR9x.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - Princes Familiar to: /tmp/tmps1Gzt1.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - I Was Hoping to: /tmp/tmpCtAF60.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - Ironic to: /tmp/tmpmKAy53.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - These R the Thoughts to: /tmp/tmpX1q54b.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - King of Pain to: /tmp/tmpgIvwSw.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - You Oughta Know to: /tmp/tmpXkP0m3.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - MTV Unplugged - Uninvited to: /tmp/tmpsmX91g.jpeg
embedart: compare PHASH score is 4.23103
embedart: media file already contained art
embedart: Removing album art file for Alanis Morissette - MTV Unplugged
Sending event: database_change
Sending event: database_change
fetchart: Alanis Morissette - MTV Unplugged: found album art
Sending event: cli_exit

And here is the version without any modification:

b6@funf:~$ beet -vv fetchart Alanis
user configuration: /home/b6/.config/beets/config.yaml
data directory: /home/b6/.config/beets
plugin paths: 
Sending event: pluginload
artresizer: method is (2, (6, 8, 9))
inline: adding item field multidisc
library database: /home/b6/music/library/good.blb
library directory: /home/b6/music/library/good
Sending event: library_opened
fetchart: trying source coverart for album Alanis Morissette - Jagged Little Pill
fetchart: downloading image: http:https://coverartarchive.org/release/0838ba20-a571-4b3c-8c0c-a31436d373b3/front
fetchart: downloaded art to: /tmp/tmp20MYUM.jpg
fetchart: image size: (1425, 1425)
fetchart: image needs resizing (1425 > 500)
fetchart: using remote image /tmp/tmp20MYUM.jpg
artresizer: ImageMagick resizing /tmp/tmp20MYUM.jpg to /tmp/tmpQqXac_.jpg
Sending event: art_set
embedart: Resizing album art to 500 pixels wide
artresizer: ImageMagick resizing /home/b6/music/library/good/Alanis Morissette/1995 - Jagged Little Pill/cover.jpg to /tmp/tmpIqr2ka.jpg
embedart: Embedding album art into Alanis Morissette - Jagged Little Pill
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - All I Really Want to: /tmp/tmpwVRwx5.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - You Oughta Know to: /tmp/tmpgKTkLC.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Perfect to: /tmp/tmpOJQtFr.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - You Learn to: /tmp/tmpHZTR21.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Head Over Feet to: /tmp/tmpMKYeQb.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Mary Jane to: /tmp/tmpDUaGDH.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Ironic to: /tmp/tmp7yDSfy.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Not the Doctor to: /tmp/tmpRxaP4l.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - Wake Up to: /tmp/tmpUGIj6D.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Extracting album art from: Alanis Morissette - Jagged Little Pill - You Oughta Know (Jimmy the Saint Blend) / Your House to: /tmp/tmpqICb6N.jpeg
embedart: compare PHASH score is 0.0237579
embedart: media file already contained art
embedart: Removing album art file for Alanis Morissette - Jagged Little Pill
Sending event: database_change
Sending event: database_change
fetchart: Alanis Morissette - Jagged Little Pill: found album art
fetchart: trying source coverart for album Alanis Morissette - MTV Unplugged
fetchart: downloading image: http:https://coverartarchive.org/release/a4a547a5-b884-4642-b33b-138682278cb1/front
fetchart: downloaded art to: /tmp/tmpYbrCFJ.jpg
fetchart: image size: (1410, 1395)
fetchart: image is not square (1410 != 1395)
fetchart: downloading image: http:https://coverartarchive.org/release-group/1f57afa7-4a14-37b4-a196-572738fa5ebb/front
fetchart: downloaded art to: /tmp/tmpssPGTk.jpg
fetchart: image size: (1410, 1395)
fetchart: image is not square (1410 != 1395)
fetchart: trying source albumart for album Alanis Morissette - MTV Unplugged
fetchart: getting URL: http:https://www.albumart.org/index_detail.php?asin=B00002MZ12
fetchart: scraped art URL: http:https://www.albumart.org/index_detail.php?asin=B00002MZ12
fetchart: no image found on page
fetchart: trying source amazon for album Alanis Morissette - MTV Unplugged
fetchart: downloading image: http:https://images.amazon.com/images/P/B00002MZ12.01.LZZZZZZZ.jpg
fetchart: downloaded art to: /tmp/tmprP5GJd.jpg
fetchart: image size: (500, 494)
fetchart: image is not square (500 != 494)
fetchart: downloading image: http:https://images.amazon.com/images/P/B00002MZ12.02.LZZZZZZZ.jpg
fetchart: downloaded art to: /tmp/tmpfuM5Ut.jpg
fetchart: image size: (500, 494)
fetchart: image is not square (500 != 494)
fetchart: trying source wikipedia for album Alanis Morissette - MTV Unplugged
fetchart: getting URL: http:https://dbpedia.org/sparql?query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0A+++++++++++++++++PREFIX+dbpprop%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0A+++++++++++++++++PREFIX+owl%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0A+++++++++++++++++PREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A+++++++++++++++++PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0A%0A+++++++++++++++++SELECT+DISTINCT+%3FpageId+%3FcoverFilename+WHERE+%7B%0A+++++++++++++++++++%3Fsubject+owl%3AwikiPageID+%3FpageId+.%0A+++++++++++++++++++%3Fsubject+dbpprop%3Aname+%3Fname+.%0A+++++++++++++++++++%3Fsubject+rdfs%3Alabel+%3Flabel+.%0A+++++++++++++++++++%7B+%3Fsubject+dbpprop%3Aartist+%3Fartist+%7D%0A+++++++++++++++++++++UNION%0A+++++++++++++++++++%7B+%3Fsubject+owl%3Aartist+%3Fartist+%7D%0A+++++++++++++++++++%7B+%3Fartist+foaf%3Aname+%22Alanis+Morissette%22%40en+%7D%0A+++++++++++++++++++++UNION%0A+++++++++++++++++++%7B+%3Fartist+dbpprop%3Aname+%22Alanis+Morissette%22%40en+%7D%0A+++++++++++++++++++%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2FAlbum%3E+.%0A+++++++++++++++++++%3Fsubject+dbpprop%3Acover+%3FcoverFilename+.%0A+++++++++++++++++++FILTER+%28+regex%28%3Fname%2C+%22MTV+Unplugged%22%2C+%22i%22%29+%29%0A++++++++++++++++++%7D%0A+++++++++++++++++Limit+1&timeout=2500&format=application%2Fsparql-results%2Bjson
fetchart: getting URL: http:https://en.wikipedia.org/w/api.php?titles=File%3AAlanis+Unplugged+album+cover.jpg&format=json&prop=imageinfo&continue=&action=query&iiprop=url
Traceback (most recent call last):
  File "/home/b6/.local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.16', 'console_scripts', 'beet')()
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1207, in main
    _raw_main(args)
  File "/home/b6/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1197, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 457, in func
    self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 593, in batch_fetch_art
    path = self.art_for_album(album, local_paths)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 565, in art_for_album
    for url in self._source_urls(album):
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 618, in _source_urls
    for url in urls:
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 304, in get
    headers={'content-type': 'application/json'},
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 93, in request
    return _logged_get(self._log, *args, **kwargs)
  File "/home/b6/.local/lib/python2.7/site-packages/beetsplug/fetchart.py", line 80, in _logged_get
    return s.send(prepped, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 595, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 189, in resolve_redirects
    allow_redirects=False,
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 308, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 826, in send
    self.sock.sendall(data)
  File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 208, in sendall
    return self.connection.sendall(data)
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 969, in sendall
    raise TypeError("buf must be a byte string")
TypeError: buf must be a byte string

Hope that helps

@sampsyo sampsyo added bug bugs that are confirmed and actionable needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." and removed needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." bug bugs that are confirmed and actionable labels Jan 11, 2016
@sampsyo
Copy link
Member

sampsyo commented Jan 11, 2016

Thank you again for all the digging.

Bizarrely, I'm still having trouble reproducing it. Here's the script that should trigger the crash:

import logging
from beetsplug import fetchart

class Album(object):
    pass

album = Album()
album.albumartist = 'Alanis Morissette'
album.album = 'MTV Unplugged'

w = fetchart.Wikipedia(logging.getLogger(), None)
print(list(w.get(album)))

But on my system:

$ python t.py
[u'https://upload.wikimedia.org/wikipedia/en/6/6d/Alanis_Unplugged_album_cover.jpg']

I'm suspicious that this might be a pyOpenSSL bug that's since been fixed. Here are some rumblings elsewhere: https://github.com/kennethreitz/requests/issues/2113 pyca/pyopenssl#15

@Phyks and @Niols, which platform are you on? Can you check your versions of requests and pyOpenSSL?

Even though I'm flying blind here, I have a guess—so I'm pushing a potential fix. Can I ask you one more favor in checking whether it happens to fix the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature."
Projects
None yet
Development

No branches or pull requests

4 participants