Пример #1
0
	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)
		getattr(self, "_execute_%s" % cmd)()
Пример #2
0
    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)
        getattr(self, "_execute_%s" % cmd)()
Пример #3
0
    def execute_cmd(self, cmd):
        self.status = mpdh.status(self.client)
        if not self.status:
            aprint(1, _('Unable to connect to MPD.\n'
                'Please check your Sonata preferences or MPD_HOST/MPD_PORT'
                'environment variables.'))
            sys.exit(1)

        self.songinfo = mpdh.currsong(self.client)
        getattr(self, '_execute_%s' % cmd)()
Пример #4
0
	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
Пример #5
0
    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