def _execute_info(self): if self.status['state'] in ['play', 'pause']: cmds = [(_('Title'), ('title',)), (_('Artist'), ('artist',)), (_('Album'), ('album',)), (_('Date'), ('date',)), (_('Track'), ('track', '0', False, 2)), (_('Genre'), ('genre',)), (_('File'), ('file',)), ] for pretty, cmd in cmds: mpdh.conout('%s: %s' % (pretty, mpdh.get(self.songinfo, *cmd))) at, _length = [int(c) for c in self.status['time'].split(':')] at_time = misc.convert_time(at) try: time = misc.convert_time(mpdh.get(self.songinfo, 'time', '', True)) aprint(3, '%s: %s/%s' % (_('Time'), at_time, time)) except: aprint(3, '%s: %s' % (_('Time'), at_time)) aprint(3, '%s: %s' % (_('Bitrate'), self.status.get('bitrate', ''))) else: aprint(3, _('MPD stopped'))
def _execute_info(self): if self.status["state"] in ["play", "pause"]: cmds = [ (_("Title"), ("title",)), (_("Artist"), ("artist",)), (_("Album"), ("album",)), (_("Date"), ("date",)), (_("Track"), ("track", "0", False, 2)), (_("Genre"), ("genre",)), (_("File"), ("file",)), ] for pretty, cmd in cmds: mpdh.conout("%s: %s" % (pretty, mpdh.get(self.songinfo, *cmd))) at, _length = [int(c) for c in self.status["time"].split(":")] at_time = misc.convert_time(at) try: time = misc.convert_time(mpdh.get(self.songinfo, "time", "", True)) print "%s: %s/%s" % (_("Time"), at_time, time) except: print "%s: %s" % (_("Time"), at_time) print "%s: %s" % (_("Bitrate"), self.status.get("bitrate", "")) else: print _("MPD stopped")
def _execute_info(self): if self.status['state'] in ['play', 'pause']: cmds = [ (_("Title"), ('title', )), (_("Artist"), ('artist', )), (_("Album"), ('album', )), (_("Date"), ('date', )), (_("Track"), ('track', '0', False, 2)), (_("Genre"), ('genre', )), (_("File"), ('file', )), ] for pretty, cmd in cmds: mpdh.conout("%s: %s" % (pretty, mpdh.get(self.songinfo, *cmd))) at, _length = [int(c) for c in self.status['time'].split(':')] at_time = misc.convert_time(at) try: time = misc.convert_time( mpdh.get(self.songinfo, 'time', '', True)) print "%s: %s/%s" % (_("Time"), at_time, time) except: print "%s: %s" % (_("Time"), at_time) print "%s: %s" % (_("Bitrate"), self.status.get('bitrate', '')) else: print _("MPD stopped")
def _execute_info(self): if self.status['state'] in ['play', 'pause']: cmds = [(_("Title"), ('title',)), (_("Artist"), ('artist',)), (_("Album"), ('album',)), (_("Date"), ('date',)), (_("Track"), ('track', '0', False, 2)), (_("Genre"), ('genre',)), (_("File"), ('file',)), ] for pretty, cmd in cmds: mpdh.conout("%s: %s" % (pretty, mpdh.get(self.songinfo, *cmd))) at, _length = [int(c) for c in self.status['time'].split(':')] at_time = misc.convert_time(at) try: time = misc.convert_time(mpdh.get(self.songinfo, 'time', '', True)) print "%s: %s/%s" % (_("Time"), at_time, time) except: print "%s: %s" % (_("Time"), at_time) print "%s: %s" % (_("Bitrate"), self.status.get('bitrate', '')) else: print _("MPD stopped")
def execute_cmd(self, cmd): self.status = mpdh.status(self.client) if not self.status: print _("Unable to connect to MPD.\nPlease check your Sonata preferences or MPD_HOST/MPD_PORT environment variables.") sys.exit(1) self.songinfo = mpdh.currsong(self.client) if cmd == "play": mpdh.call(self.client, 'play') elif cmd == "pause": mpdh.call(self.client, 'pause', 1) elif cmd == "stop": mpdh.call(self.client, 'stop') elif cmd == "next": mpdh.call(self.client, 'next') elif cmd == "prev": mpdh.call(self.client, 'previous') elif cmd == "random": if self.status['random'] == '0': mpdh.call(self.client, 'random', 1) else: mpdh.call(self.client, 'random', 0) elif cmd == "repeat": if self.status['repeat'] == '0': mpdh.call(self.client, 'repeat', 1) else: mpdh.call(self.client, 'repeat', 0) elif cmd == "pp": if self.status['state'] in ['play']: mpdh.call(self.client, 'pause', 1) elif self.status['state'] in ['pause', 'stop']: mpdh.call(self.client, 'play') elif cmd == "info": if self.status['state'] in ['play', 'pause']: mpdh.conout (_("Title") + ": " + mpdh.get(self.songinfo, 'title')) mpdh.conout (_("Artist") + ": " + mpdh.get(self.songinfo, 'artist')) mpdh.conout (_("Album") + ": " + mpdh.get(self.songinfo, 'album')) mpdh.conout (_("Date") + ": " + mpdh.get(self.songinfo, 'date')) mpdh.conout (_("Track") + ": " + mpdh.getnum(self.songinfo, 'track', '0', False, 2)) mpdh.conout (_("Genre") + ": " + mpdh.get(self.songinfo, 'genre')) mpdh.conout (_("File") + ": " + os.path.basename(mpdh.get(self.songinfo, 'file'))) at, _length = [int(c) for c in self.status['time'].split(':')] at_time = misc.convert_time(at) try: time = misc.convert_time(int(mpdh.get(self.songinfo, 'time'))) print _("Time") + ": " + at_time + " / " + time except: print _("Time") + ": " + at_time print _("Bitrate") + ": " + self.status.get('bitrate', '') else: print _("MPD stopped") elif cmd == "status": try: if self.status['state'] == 'play': print _("State") + ": " + _("Playing") elif self.status['state'] == 'pause': print _("State") + ": " + _("Paused") elif self.status['state'] == 'stop': print _("State") + ": " + _("Stopped") if self.status['repeat'] == '0': print _("Repeat") + ": " + _("Off") else: print _("Repeat") + ": " + _("On") if self.status['random'] == '0': print _("Random") + ": " + _("Off") else: print _("Random") + ": " + _("On") print _("Volume") + ": " + self.status['volume'] + "/100" print _('Crossfade') + ": " + self.status['xfade'] + ' ' + gettext.ngettext('second', 'seconds', int(self.status['xfade'])) except: pass
def execute_cmd(self, cmd): self.status = mpdh.status(self.client) if not self.status: print _( "Unable to connect to MPD.\nPlease check your Sonata preferences or MPD_HOST/MPD_PORT environment variables." ) sys.exit(1) self.songinfo = mpdh.currsong(self.client) if cmd == "play": mpdh.call(self.client, 'play') elif cmd == "pause": mpdh.call(self.client, 'pause', 1) elif cmd == "stop": mpdh.call(self.client, 'stop') elif cmd == "next": mpdh.call(self.client, 'next') elif cmd == "prev": mpdh.call(self.client, 'previous') elif cmd == "random": if self.status['random'] == '0': mpdh.call(self.client, 'random', 1) else: mpdh.call(self.client, 'random', 0) elif cmd == "repeat": if self.status['repeat'] == '0': mpdh.call(self.client, 'repeat', 1) else: mpdh.call(self.client, 'repeat', 0) elif cmd == "pp": if self.status['state'] in ['play']: mpdh.call(self.client, 'pause', 1) elif self.status['state'] in ['pause', 'stop']: mpdh.call(self.client, 'play') elif cmd == "info": if self.status['state'] in ['play', 'pause']: mpdh.conout( _("Title") + ": " + mpdh.get(self.songinfo, 'title')) mpdh.conout( _("Artist") + ": " + mpdh.get(self.songinfo, 'artist')) mpdh.conout( _("Album") + ": " + mpdh.get(self.songinfo, 'album')) mpdh.conout(_("Date") + ": " + mpdh.get(self.songinfo, 'date')) mpdh.conout( _("Track") + ": " + mpdh.getnum(self.songinfo, 'track', '0', False, 2)) mpdh.conout( _("Genre") + ": " + mpdh.get(self.songinfo, 'genre')) mpdh.conout( _("File") + ": " + os.path.basename(mpdh.get(self.songinfo, 'file'))) at, _length = [int(c) for c in self.status['time'].split(':')] at_time = misc.convert_time(at) try: time = misc.convert_time( int(mpdh.get(self.songinfo, 'time'))) print _("Time") + ": " + at_time + " / " + time except: print _("Time") + ": " + at_time print _("Bitrate") + ": " + self.status.get('bitrate', '') else: print _("MPD stopped") elif cmd == "status": try: if self.status['state'] == 'play': print _("State") + ": " + _("Playing") elif self.status['state'] == 'pause': print _("State") + ": " + _("Paused") elif self.status['state'] == 'stop': print _("State") + ": " + _("Stopped") if self.status['repeat'] == '0': print _("Repeat") + ": " + _("Off") else: print _("Repeat") + ": " + _("On") if self.status['random'] == '0': print _("Random") + ": " + _("Off") else: print _("Random") + ": " + _("On") print _("Volume") + ": " + self.status['volume'] + "/100" print _('Crossfade') + ": " + self.status[ 'xfade'] + ' ' + gettext.ngettext( 'second', 'seconds', int(self.status['xfade'])) except: pass