diff --git a/skipalbum.py b/skipalbum.py new file mode 100644 index 0000000..de8af37 --- /dev/null +++ b/skipalbum.py @@ -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 :) + +