Beispiel #1
0
def alexa_play_playlist(slots):
    heard_playlist = str(slots['Playlist']['value']).lower().translate(
        None, string.punctuation)

    card_title = 'Playing playlist "%s"' % (heard_playlist)
    print card_title
    sys.stdout.flush()

    playlists = kodi.GetMusicPlaylists()
    if 'result' in playlists and 'files' in playlists['result']:
        playlists_list = playlists['result']['files']
        located = kodi.matchHeard(heard_playlist, playlists_list, 'label')

        if located:
            print 'Located playlist "%s"' % (located['file'])
            sys.stdout.flush()
            kodi.StartPlaylist(located['file'])
            return build_alexa_response(
                'Playing playlist %s' % (heard_playlist), card_title)
        else:
            return build_alexa_response(
                'I Could not find a playlist named %s' % (heard_playlist),
                card_title)
    else:
        return build_alexa_response('Error parsing results', card_title)
        name_stripped = kodi.sanitize_name(v['label'], True)
        all.append(name)
        all.append(name_stripped)

cleaned = list(set(all))
cleaned = filter(None, cleaned)
random.shuffle(cleaned)
cleaned = cleaned[:300]

gfile = open('MUSICSONGS', 'w')
for a in cleaned:
    gfile.write("%s\n" % a)
gfile.close()

# Generate MUSICPLAYLISTS Slot
retrieved = kodi.GetMusicPlaylists()

all = []

if 'result' in retrieved and 'files' in retrieved['result']:
    for v in retrieved['result']['files']:
        name = kodi.sanitize_name(v['label'])
        name_stripped = kodi.sanitize_name(v['label'], True)
        all.append(name)
        all.append(name_stripped)

cleaned = list(set(all))
cleaned = filter(None, cleaned)
random.shuffle(cleaned)
cleaned = cleaned[:300]