-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpdNoHeino.py
executable file
·62 lines (46 loc) · 1.31 KB
/
mpdNoHeino.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from mpd import MPDClient, CommandError
from socket import error as SocketError
from sys import exit
### SETTINGS ###
HOST = 'localhost'
PORT = '6600'
PASSWORD = False
unwantedStrings = ['heino', 'quack']
client = MPDClient()
try:
client.connect(host=HOST, port=PORT)
except SocketError as ex:
print ex
exit(1)
if PASSWORD:
try:
client.password(PASSWORD)
except CommandError as ex:
print ex
exit(1)
print client.status()
removeItems = []
for itm in client.playlistinfo():
foundBad = False
for unwanted in unwantedStrings:
for val in itm.itervalues():
if unwanted in val.lower():
removeItems.append(itm['id'])
print unwanted,'=>',val,'IN:', itm
foundBad = True
break
if foundBad == True:
break
#if unwanted in itm['name'].lower() or unwanted in itm['file'].lower() or unwanted in itm['title'].lower():
#removeItems.append(itm['id'])
for itmId in removeItems:
client.deleteid(itmId)
if len(removeItems) > 0:
print '*********************'
print 'Removed',len(removeItems),'HEINOS'
print '*********************'
else:
print 'theres no HEINO'
client.disconnect()