Skip to content

GMusic album parsing can crash skill initialization #26

@ProjectMoon

Description

@ProjectMoon

Mopidy 3 is returning some entries that look like this:

    {
      "__model__": "Ref",
      "uri": "gmusic:album:<id>",
      "name": "Unknown Album",
      "type": "directory"
    }

The list comprehension assumes the name is Artist - Album. When it encounters an entry like this, the list comprehension crashes and ultimately aborts the entire skill initialization process.

This specifically affects the get_gmusic_artists method in mopidy_post.py.

It could be changed to something like this:

def parse_album(gmusic_name):
    try:
        return e.split(' - ')[1]
    except:
        return e


def get_gmusic_albums(self):
    p = self.browse('gmusic:album')
    p = {e['name']: e for e in p if e['type'] == 'directory'}
    return {parse_album(e): p[e] for e in p}

Of course, then you wind up getting duplicates (I have multiple unique Unknown Albums for some reason). A better temporary solution would probably be to either ignore these failures, or squash them all into one album as far as the skill is concerned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions