From 9f338ba2d7df74e6cf160050a8a289ded97aed08 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Tue, 11 Nov 2014 00:41:51 +0100 Subject: [PATCH] =?UTF-8?q?Skip=20album=20skript=20f=C3=BCr=20mpd,=20weil?= =?UTF-8?q?=20bsod=20eins=20wollte=20und=20ich=20eh=20langeweile=20hab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skipalbum.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 skipalbum.py 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 :) + +