summaryrefslogtreecommitdiffstats
path: root/feeding_example.py
blob: d9bde2bdde4fd12118791896b6af91ec8b2def18 (plain)
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
#!/usr/bin/env python
from mpdrast import MPDrastClient
from os import environ

mpd_host = environ.get("MPD_HOST", "localhost")
mpd_port = environ.get("MPD_PORT", 6600)

m = MPDrastClient()
m.connect_from_env(mpd_host, mpd_port)

# the user can run mpc update before; wait for completion
m.wait_for_update()

# get all "final" directories
nb_dirs = len(m.get_final_dirs())
print "We have found %s albums." % nb_dirs

# if the playlist is empty, add one random album
while m.is_playlist_hungry(100) and nb_dirs:
    rdir = m.get_random_dir()
    m.add(rdir)
    print "Added %s" % rdir

print m.status()
print m.stats()