thomasvs / morituri

For those about to RIP - a Unix CD ripper preferring accuracy over speed
GNU General Public License v3.0
301 stars 42 forks source link

morituri crashes with KeyError when MusicBrainz entry only stub, not release #50

Open runejuhl opened 10 years ago

runejuhl commented 10 years ago

When trying to rip a CD, morituri crashes with a KeyError when a matching CD entry is created only as a stub, not a full release:

Traceback (most recent call last):
  File "/usr/bin/rip", line 35, in <module>
    sys.exit(main.main(sys.argv[1:]))
  File "/usr/lib/python2.7/dist-packages/morituri/rip/main.py", line 33, in main
    ret = c.parse(argv)
  File "/usr/lib/python2.7/dist-packages/morituri/rip/main.py", line 111, in parse
    logcommand.LogCommand.parse(self, argv)
  File "/usr/lib/python2.7/dist-packages/morituri/extern/command/command.py", line 385, in parse
    return self.subCommands[command].parse(args[1:])
  File "/usr/lib/python2.7/dist-packages/morituri/extern/command/command.py", line 385, in parse
    return self.subCommands[command].parse(args[1:])
  File "/usr/lib/python2.7/dist-packages/morituri/extern/command/command.py", line 347, in parse
    ret = self.do(args)
  File "/usr/lib/python2.7/dist-packages/morituri/rip/cd.py", line 183, in do
    release=self.options.release_id)
  File "/usr/lib/python2.7/dist-packages/morituri/common/program.py", line 242, in getMusicBrainz
    record=self._record)
  File "/usr/lib/python2.7/dist-packages/morituri/common/ourmusicbrainzngs.py", line 250, in musicbrainz
    len(result['disc']['release-list']),
KeyError: 'disc'

When the entry is only a stub, the result dict is as follows (for http://musicbrainz.org/release/c5b8c421-0a13-4937-8b65-e887350cb404)

{'cdstub': {'title': 'Vil du med i skoven', 'barcode': '5709283009131', 'track-list': [{'length': '173000', 'track_or_recording_length': '173000', 'title': 'Skovsangen'}, {'length': '160000', 'track_or_recording_length': '160000', 'title': 'Missen'}, {'length': '112000', 'track_or_recording_length': '112000', 'title': 'Min cykel'}, {'length': '110000', 'track_or_recording_length': '110000', 'title': u'Spilled\xe5sen'}, {'length': '201000', 'track_or_recording_length': '201000', 'title': 'Krabben'}, {'length': '142000', 'track_or_recording_length': '142000', 'title': 'Gyngesangen'}, {'length': '289000', 'track_or_recording_length': '289000', 'title': 'I min klasse'}, {'length': '145000', 'track_or_recording_length': '145000', 'title': 'Vandsangen'}, {'length': '191000', 'track_or_recording_length': '191000', 'title': u'S\xf8skende-sang'}, {'length': '90000', 'track_or_recording_length': '90000', 'title': 'Lille Kristoffer'}, {'length': '183000', 'track_or_recording_length': '183000', 'title': 'Vintersang'}, {'length': '86000', 'track_or_recording_length': '86000', 'title': 'Rokketand'}, {'length': '182000', 'track_or_recording_length': '182000', 'title': u'Tandb\xf8rste-nova'}, {'length': '47000', 'track_or_recording_length': '47000', 'title': 'Dippedutdyr'}], 'id': 'dKk9yCMZp2fgxn910tKF8nQGW3U-', 'artist': u'Povl Kj\xf8ller'}}

When the same entry is changed into a release, the dict is this:

{'disc': {'release-list': [{'status': 'Official', 'artist-credit': [{'artist': {'sort-name': u'Kj\xf8ller, Povl', 'id': '742b5517-f1dd-4aa7-9e10-55d0b6c9baae', 'name': u'Povl Kj\xf8ller'}}], 'title': 'Vil du med i skoven', 'country': 'DK', 'barcode': '5709283009131', 'medium-list': [{'disc-list': [{'id': 'dKk9yCMZp2fgxn910tKF8nQGW3U-', 'sectors': '158475'}], 'position': '1', 'track-list': [{'recording': {'length': '173000', 'id': '99bac95e-721f-4e68-82e8-3d7c8a37cfd6', 'title': 'Skovsangen'}, 'position': '1', 'length': '173000', 'number': '1', 'track_or_recording_length': '173000'}, {'recording': {'length': '160000', 'id': 'bb1463ee-789a-49d2-b1ea-88382904274b', 'title': 'Missen'}, 'position': '2', 'length': '160000', 'number': '2', 'track_or_recording_length': '160000'}, {'recording': {'length': '112000', 'id': '9f7bd598-672d-49e7-89da-8bb2bcf58d95', 'title': 'Min cykel'}, 'position': '3', 'length': '112000', 'number': '3', 'track_or_recording_length': '112000'}, {'recording': {'length': '110000', 'id': '1af6a4b2-b493-4e96-b62a-32e251068dc0', 'title': u'Spilled\xe5sen'}, 'position': '4', 'length': '110000', 'number': '4', 'track_or_recording_length': '110000'}, {'recording': {'length': '201000', 'id': 'abe3eabe-442b-40a6-a211-49af8aaa1a7f', 'title': 'Krabben'}, 'position': '5', 'length': '201000', 'number': '5', 'track_or_recording_length': '201000'}, {'recording': {'length': '142000', 'id': 'a286b5df-f2ce-4641-aa88-8b1671e6a243', 'title': 'Gyngesangen'}, 'position': '6', 'length': '142000', 'number': '6', 'track_or_recording_length': '142000'}, {'recording': {'length': '289000', 'id': 'fd35dbe5-64df-4441-8783-e2feef6bb733', 'title': 'I min klasse'}, 'position': '7', 'length': '289000', 'number': '7', 'track_or_recording_length': '289000'}, {'recording': {'length': '145000', 'id': '27d08d29-acee-4a90-8cfb-1a4b5d0a2b56', 'title': 'Vandsangen'}, 'position': '8', 'length': '145000', 'number': '8', 'track_or_recording_length': '145000'}, {'recording': {'length': '191000', 'id': '2600eb27-d51e-4ac4-8416-45f2c648ad88', 'title': u'S\xf8skende-sang'}, 'position': '9', 'length': '191000', 'number': '9', 'track_or_recording_length': '191000'}, {'recording': {'length': '90000', 'id': '72488fc6-056c-4a56-8885-012ec6e077ef', 'title': 'Lille Kristoffer'}, 'position': '10', 'length': '90000', 'number': '10', 'track_or_recording_length': '90000'}, {'recording': {'length': '183000', 'id': 'de16a798-ac02-47d1-89e2-cd76ecf07453', 'title': 'Vintersang'}, 'position': '11', 'length': '183000', 'number': '11', 'track_or_recording_length': '183000'}, {'recording': {'length': '86000', 'id': '6d9a5bc9-5603-47db-abf7-96f7639ee4c0', 'title': 'Rokketand'}, 'position': '12', 'length': '86000', 'number': '12', 'track_or_recording_length': '86000'}, {'recording': {'length': '182000', 'id': '989dde77-97b8-470f-8461-292f79534edf', 'title': u'Tandb\xf8rste-nova'}, 'position': '13', 'length': '182000', 'number': '13', 'track_or_recording_length': '182000'}, {'recording': {'length': '47000', 'id': 'f91f172d-545f-4b9d-ba99-949ee6ceb344', 'title': 'Dippedutdyr'}, 'position': '14', 'length': '47000', 'number': '14', 'track_or_recording_length': '47000'}], 'format': 'CD'}], 'packaging': 'Jewel Case', 'release-group': {'first-release-date': '2009', 'title': 'Vil du med i skoven', 'type': 'Album', 'id': 'ab57c0b1-fe31-43b8-b5f9-51948f8a41a3', 'primary-type': 'Album'}, 'text-representation': {'language': 'dan', 'script': 'Arab'}, 'date': '2009', 'artist-credit-phrase': u'Povl Kj\xf8ller', 'quality': 'normal', 'id': 'c5b8c421-0a13-4937-8b65-e887350cb404'}], 'id': 'dKk9yCMZp2fgxn910tKF8nQGW3U-', 'sectors': '158475'}}
asayler commented 10 years ago

I'm seeing this same issue.

erichlf commented 10 years ago

Same here on version 0.2.0

Freso commented 10 years ago

@erichlf 0.2.0 is rather old. Are you still seeing this with 0.2.3?

erichlf commented 10 years ago

I am using the latest version available from apt-get in Ubuntu 13.10. I have found an alternative and don't feel like trying to compile.

Freso commented 10 years ago

If you see the bug with apt-get in Ubuntu 13.10, then file a bug with Ubuntu. I'm fairly certain this issue has already been fixed in morituri for quite some time.