Skip album skript für mpd, weil bsod eins wollte und ich eh langeweile hab
This commit is contained in:
parent
09ac2aecbd
commit
9f338ba2d7
1 changed files with 36 additions and 0 deletions
36
skipalbum.py
Normal file
36
skipalbum.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import mpd
|
||||||
|
from sys import argv,exit
|
||||||
|
|
||||||
|
host = "localhost"
|
||||||
|
port = 6600
|
||||||
|
|
||||||
|
if len(argv) > 1:
|
||||||
|
host = argv[1]
|
||||||
|
|
||||||
|
if len(argv) > 2:
|
||||||
|
try:
|
||||||
|
port = int(argv[2])
|
||||||
|
except Exception:
|
||||||
|
print("Port must be a number")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
client = mpd.MPDClient(use_unicode=True)
|
||||||
|
try: #Connect
|
||||||
|
client.connect(host,port)
|
||||||
|
except SocketError:
|
||||||
|
print("Could not connect.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
firstsong = client.currentsong() #Get current song
|
||||||
|
if firstsong != {}: #Is there a song playing
|
||||||
|
client.next() #Skip it
|
||||||
|
currentsong = client.currentsong() #Get next song
|
||||||
|
while currentsong != {} and firstsong['artist'] == currentsong['artist'] and firstsong['album'] == currentsong['album']: #A song available and song still from same album
|
||||||
|
client.next() #Skip it
|
||||||
|
currentsong = client.currentsong() #Get next song
|
||||||
|
|
||||||
|
#Album skipped or playlist ended.
|
||||||
|
client.disconnect() #Disconnect :)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue