<gh_stars>0
UNKNOWN = u''


def describe_track(track):
    """
    Prepare a short human-readable Track description.

    track (mopidy.models.Track): Track to source song data from.
    """
    title = track.name or UNKNOWN

    # Simple/regular case: normal song (e.g. from Spotify).
    if track.artists:
        artist = next(iter(track.artists)).name
    elif track.album and track.album.artists:  # Album-only artist case.
        artist = next(iter(track.album.artists)).name
    else:
        artist = UNKNOWN

    if track.album and track.album.name:
        album = track.album.name
    else:
        album = UNKNOWN

    return u';'.join([title, artist, album])


def describe_stream(raw_title):
    """
    Attempt to parse given stream title in very rudimentary way.
    """
    title = UNKNOWN
    artist = UNKNOWN
    album = UNKNOWN

    # Very common separator.
    if '-' in raw_title:
        parts = raw_title.split('-')
        artist = parts[0].strip()
        title = parts[1].strip()
    else:
        # Just assume we only have track title.
        title = raw_title

    return u';'.join([title, artist, album])

UNKNOWN = u''


def describe_track(track):
    """
    Prepare a short human-readable Track description.

    track (mopidy.models.Track): Track to source song data from.
    """
    title = track.name or UNKNOWN

    # Simple/regular case: normal song (e.g. from Spotify).
    if track.artists:
        artist = next(iter(track.artists)).name
    elif track.album and track.album.artists:  # Album-only artist case.
        artist = next(iter(track.album.artists)).name
    else:
        artist = UNKNOWN

    if track.album and track.album.name:
        album = track.album.name
    else:
        album = UNKNOWN

    return u';'.join([title, artist, album])


def describe_stream(raw_title):
    """
    Attempt to parse given stream title in very rudimentary way.
    """
    title = UNKNOWN
    artist = UNKNOWN
    album = UNKNOWN

    # Very common separator.
    if '-' in raw_title:
        parts = raw_title.split('-')
        artist = parts[0].strip()
        title = parts[1].strip()
    else:
        # Just assume we only have track title.
        title = raw_title

    return u';'.join([title, artist, album])
Prepare a short human-readable Track description.      track (mopidy.models.Track): Track to source song data from. # Simple/regular case: normal song (e.g. from Spotify). # Album-only artist case. Attempt to parse given stream title in very rudimentary way. # Very common separator. # Just assume we only have track title.