-
-
Save fabjan/109665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mpd | |
import curses | |
class Mjolnir(object): | |
'''Main Mjolnir class''' | |
def __init__(self, hostname, port): | |
'''Mjolnir constructor''' | |
self.__connected = False | |
self.__hostname = hostname | |
self.__port = port | |
self.__screen = curses.initscr() | |
self.__client = mpd.MPDClient() | |
def start_cursing(self): | |
self.connect() | |
'''Starts cursing''' | |
self.screen.border(1) | |
_song = self.client.currentsong() | |
_songstr = _song['artist'] + ' - ' + _song['title'] | |
self.screen.addstr(12, 25, _songstr) | |
self.screen.refresh() | |
self.screen.getch() | |
def stop_cursing(self): | |
'''Stops cursing''' | |
curses.endwin() | |
def main(self): | |
'''Main method''' | |
self.start_cursing() | |
self.stop_cursing() | |
self.client.close() | |
self.client.disconnect() | |
def get_screen(self): | |
return self.__screen | |
def get_client(self): | |
return self.__client | |
def connect(self): | |
if connected == False: | |
self.client.connect(self.__hostname, self.__port) | |
self.__connected = True | |
else: | |
raise Exception, "There's no connection to the MPD server" | |
class Playlist(object): | |
''' Class for playlist ''' | |
def __init__(self): | |
pass | |
playlist = Playlist() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment