Ejemplo n.º 1
0
def action_fav_play(data, n):
    p, config = data
    ip = config.get("connection", "ip")
    username = config.get("connection", "username")
    password = config.get("connection", "password")
    connection.mpal_init_login(ip, username, password)
    connection.mpal_play_fav(ip, n)
Ejemplo n.º 2
0
def action_on(data):
    p, config = data
    ip = config.get("connection", "ip")
    username = config.get("connection", "username")
    password = config.get("connection", "password")
    connection.mpal_init_login(ip, username, password)
    connection.mpal_power_up(ip)
Ejemplo n.º 3
0
def action_volume_set(data, volume):
    p, config = data
    ip = config.get("connection", "ip")
    username = config.get("connection", "username")
    password = config.get("connection", "password")
    connection.mpal_init_login(ip, username, password)
    connection.mpal_set_volume(ip, float(volume))
    print "Volume set to %d%%." % float(volume) 
Ejemplo n.º 4
0
def action_play(data, path=None):
    if not path:
        print "Stream url missing."
    else:
        p, config = data
        ip = config.get("connection", "ip")
        username = config.get("connection", "username")
        password = config.get("connection", "password")
        connection.mpal_init_login(ip, username, password)
        connection.mpal_play_stream(ip, path)
Ejemplo n.º 5
0
def action_volume(data, volume=None):
    p, config = data
    if volume == None:
        ip = config.get("connection", "ip")
        username = config.get("connection", "username")
        password = config.get("connection", "password")
        connection.mpal_init_login(ip, username, password)
        vol = connection.mpal_get_volume(ip)
        print "Volume: %d%%" % vol
    else:
        action_volume_set(data, volume)
Ejemplo n.º 6
0
def action_fav(data, n=None):
    p, config = data
    if n == None:
        ip = config.get("connection", "ip")
        username = config.get("connection", "username")
        password = config.get("connection", "password")
        connection.mpal_init_login(ip, username, password)
        favs = connection.mpal_get_favs(ip)
        print "Available Favorites:"
        for fav in favs:
            id, name = fav
            print "%2d  %s" % (id, name)
        print "To play a favorite station, run"
        print "\tmpal fav <id>"
    else:
        action_fav_play(data, n)
Ejemplo n.º 7
0
def action_default(data):
    p, config = data
    ip = config.get("connection", "ip")
    username = config.get("connection", "username")
    password = config.get("connection", "password")
    connection.mpal_init_login(ip, username, password)
    
    running = connection.mpal_is_running(ip)
    playing = connection.mpal_get_now_playing(ip)
    volume = float(connection.mpal_get_volume(ip))
    
    status = "running" if running else "sleeping"
    playing = playing if playing else "not playing"
    
    print "Address: %s" % ip
    print "Status: %s" % status
    print "Now playing: %s" % playing
    print "Volume: %d%%" % volume