Esempio n. 1
0
    def __init__(self):
        GPIO.setmode(GPIO.BOARD)

        self.display = LCDDisplay.LCDThread()

        self.display.spool_string_value("GPM-Connecting..", "Please wait     ")

        self.mus = Mobileclient()
        fd = open('Secret.txt', 'r')
        data = fd.read().split("\n")
        fd.close()
        self.mus.login(data[0], data[1], Mobileclient.FROM_MAC_ADDRESS)

        self.Lib = self.mus.get_all_songs()
        self.playlists = self.mus.get_all_user_playlist_contents()

        tplay = self.playlists
        self.playlists = {}

        self.index = 0

        for pl in tplay:
            out = self.append_song_to_playlist(pl, songs=self.Lib)
            self.playlists[out["name"]] = out

        self.lists_w_id = [{'quit': 0}]
        for item in self.playlists.values():
            self.lists_w_id.append({item["name"]: item["id"]})

        self.display.spool_string_value("Ready           ", "Awaiting input  ")
        self.button_set_up()
        self.display.spool_string_value(
            self.lists_w_id[self.index].items()[0][0][:16])

        self.player = MusicPlayer.PlayerThread(self.playlists, self.display,
                                               self, self.Lib)
        self.working = True

        try:
            while self.working:
                time.sleep(10)
        except KeyboardInterrupt:
            pass
        finally:
            self.display.spool_string_value("Stopping...", "Have a nice day")
            self.end_clear()