File: randomqueue.py

package info (click to toggle)
python-mpd 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 472 kB
  • sloc: python: 3,148; makefile: 201; sh: 9
file content (36 lines) | stat: -rw-r--r-- 567 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# IMPORTS
from mpd import MPDClient, CommandError
from random import choice
from socket import error as SocketError
from sys import exit


## SETTINGS
##
HOST = "localhost"
PORT = "6600"
PASSWORD = False
###


client = MPDClient()

try:
    client.connect(host=HOST, port=PORT)
except SocketError:
    exit(1)

if PASSWORD:
    try:
        client.password(PASSWORD)
    except CommandError:
        exit(1)

client.add(choice(client.list("file")))
client.disconnect()

# VIM MODLINE
# vim: ai ts=4 sw=4 sts=4 expandtab