示例#1
0
 def toggleShuffle(self):
     self.getTrackInfo()
     if self.status['random']:
         mpdclient2.connect().random(0)
         output("Random off")
     else:
         mpdclient2.connect().random(1)
         output("Random on")
示例#2
0
 def toggleRepeat(self):
     self.getTrackInfo()
     if self.status['repeat']:
         mpdclient2.connect().repeat(0)
         output("Repeat off")
     else:
         mpdclient2.connect().repeat(1)
         output("Repeat on")
示例#3
0
文件: tmpc.py 项目: gaving/tmpc
 def on_play_track_clicked_cb(self, widget, artist, title):
     # This is just... awful.
     for song in self.playlist:
         try:
             if song['artist'] == artist and song['title'] == title:
                 mpdclient2.connect().playid(int(song['id']))
                 debug("* Trying to play album track with id: %d (%s - %s)" % \
                 (int(song['id']), artist, title))
                 break
         except KeyError:
             pass
示例#4
0
    def post_new(self, type, **args):

        m = mpdclient2.connect()
        if not m:
            return MpcPost(randstr(), "offline", m.currentsong())

        return MpcPost(randstr(), "online", m.currentsong())
示例#5
0
 def drawBanner(self):
     conn = mpdclient2.connect()
     self.buffer[-1] = "Playlist length: %s" % conn.status()['playlist']
     if conn.status().has_key('time'):
         self.buffer.append("Total time: %s" % conn.status()['time'])
     self.buffer.append('-'*25)
     self.buffer.append('')
示例#6
0
def browse(request, path):
    context = {'next': request.path,
               'page': "browse",
               }

    try:
        m = mpdclient2.connect()
    except socket.error:
        m = False

    if m:
        playlistinfo = m.playlistinfo()
        if not path:
            list = m.lsinfo()
        else:
            list = m.lsinfo(path)

        currentsong = m.currentsong()
        status = m.status()
        if currentsong and hasattr(status, 'time'):
            time = get_track_time(status.time) 
            context['time'] = time

        context['list'] = list
        context['currentsong'] = currentsong
        context['status'] = status
        context['playlist'] = playlistinfo
    else:
        context = {'errors': ['could not connect to server']}

    return render_with_request(request, 'babik/browse.html', context)
示例#7
0
def playlist(request):
    context = {'next': request.path,
               'page': "playlist",
               }
    try:
        m = mpdclient2.connect()
    except socket.error:
        m = False

    if m:
        playlistinfo = m.playlistinfo()
        currentsong = m.currentsong()
        status = m.status()
        if hasattr(currentsong, 'artist') and hasattr(status, 'time'):
            time = get_track_time(status.time) 
            context['time'] = time
            context['currentsong'] = currentsong

        context['playlist'] = playlistinfo
        context['status'] = status

    else:
        context = {'errors': ['could not connect to server']}

    return render_with_request(request, 'babik/playlist.html', context)
示例#8
0
文件: views.py 项目: blenderbox/bagel
def browse(request, path):
    context = {"next": request.path, "page": "browse", "media_url": settings.MEDIA_URL}

    try:
        m = mpdclient2.connect()
    except socket.error:
        m = False

    if m:
        playlistinfo = m.playlistinfo()
        if not path:
            list = m.lsinfo()
        else:
            list = m.lsinfo(path)

        currentsong = m.currentsong()
        status = m.status()
        if currentsong and hasattr(status, "time"):
            time = get_track_time(status.time)
            context["time"] = time

        context["list"] = list
        context["currentsong"] = currentsong
        context["status"] = status
        context["playlist"] = playlistinfo
    else:
        context = {"errors": ["could not connect to server"]}

    return render_to_response("babik/browse.html", context)
示例#9
0
    def get_cover_path(self):
        artist = self.get_artist()
        album = self.get_album()
        filename = os.path.expanduser("~/.covers/" + artist + "-" + album +
                                      ".jpg")
        if os.path.isfile(filename):
            return filename

        try:
            t = mpdclient2.connect().currentsong().file
            t = t.replace('file://', '')
            t = t.split('/')
            basePath = ''
            for l in t:
                if l.find('.') == -1:
                    basePath = basePath + l + '/'

            names = ['Album', 'Cover', 'Folde']
            for x in os.listdir(basePath):
                if os.path.splitext(x)[1] in [
                        ".jpg", ".png"
                ] and (x.capitalize()[:5] in names):
                    coverFile = basePath + x
                    return coverFile
        except:
            return ''
        return ''
示例#10
0
 def play_pause(self):
             status = mpdclient2.connect().status()
             if status.state == 'play':
                     mpdclient2.connect().pause(1)
             elif status.state == 'pause':
                     mpdclient2.connect().pause(0)
             else:
                     mpdclient2.connect().play()
示例#11
0
 def play_pause(self):
     status = mpdclient2.connect().status()
     if status.state == 'play':
         mpdclient2.connect().pause(1)
     elif status.state == 'pause':
         mpdclient2.connect().pause(0)
     else:
         mpdclient2.connect().play()
示例#12
0
	def is_active(self, dbus_iface):
		app = mpdclient2.connect()
		if not app: return False
		else: 
			proc = os.popen("""ps axo "%p,%a" | grep "last" | grep -v grep|cut -d',' -f1""").read()
			procs = proc.split('\n')
			if len(procs) > 1:
				return True
			else:
				return False
示例#13
0
文件: tmpc.py 项目: gaving/tmpc
 def on_tray_scroll_cb(self, widget, event):
     conn = mpdclient2.connect()
     current_elapsed = int(conn.status()['time'].split(':')[0])
     current_pos = int(self.track['pos'])
     if event.direction == gtk.gdk.SCROLL_UP:
         debug("* Seeking from %s -> %d" % (current_elapsed,current_elapsed+10))
         conn.seek(current_pos, current_elapsed+10)
     if event.direction == gtk.gdk.SCROLL_DOWN:
         debug("* Seeking from %s -> %d" % (current_elapsed,current_elapsed-10))
         conn.seek(current_pos, current_elapsed-10)
示例#14
0
 def getTrackInfo(self):
     conn = mpdclient2.connect()
     conn_status = conn.status()
     self.status = {
             'time' : conn_status['time'],
             'state' : conn_status['state'],
             'random' : int(conn_status['random']),
             'repeat' : int(conn_status['repeat']),
             'updating' : int(conn_status.has_key('updating_db'))
     }
     self.track = conn.currentsong()
示例#15
0
        def getLyrics(self):
            track = mpdclient2.connect().currentsong()
            artist = track['artist']
            title = track['title']

            if artist and title:
                if self.proxy.checkSongExists(artist, title):
                    info = self.proxy.getSong(artist, title)
                    return info['lyrics']

            return
示例#16
0
文件: tmpc.py 项目: gaving/tmpc
 def create_play_pause_items(self):
     if self.buttons:
         for track in self.buttons.values():
             self.menu.remove(track)
     else:
         self.buttons = {}
     if self.status['state'] == 'stop' or self.status['state'] == 'pause':
         item = gtk.ImageMenuItem(stock_id=gtk.STOCK_MEDIA_PLAY)
         item.connect("activate", lambda *args: mpdclient2.connect().play())
         self.menu.prepend(item)
         self.buttons['play'] = item
     else:
         item = gtk.ImageMenuItem(stock_id=gtk.STOCK_MEDIA_PAUSE)
         item.connect("activate", lambda *args: mpdclient2.connect().pause())
         self.menu.prepend(item)
         self.buttons['pause'] = item
         item = gtk.ImageMenuItem(stock_id=gtk.STOCK_MEDIA_STOP)
         item.connect("activate", lambda *args: mpdclient2.connect().stop())
         self.menu.prepend(item)
         self.buttons['stop'] = item
     self.menu.show_all()
示例#17
0
    def highlightCurrent(self):
        id = mpdclient2.connect().currentsong()['id']
        vim.command("match none")
        vim.command("call search('^#%s)', 'w')" % id)
        vim.command("exe 'match Visual /^#%s.*/'" % id)

        # Open a fold if we're in folded mode
        if playlist_mode == "folded":

            # Don't open a fold if the current track isn't IN one!
            if vim.eval("foldlevel('.')") != '0':
                vim.command("normal zo")

        vim.command("normal z.")
示例#18
0
def controller(request, action, songid=None):
    context = {}
    next = False

    try:
        m = mpdclient2.connect()
    except socket.error:
        m = False

    if m:
        if action == "next":
            m.next()
        elif action == "pause":
            m.pause()
        elif action == "play":
            m.play()
        elif action == "stop":
            m.stop()
        elif action == "previous":
            m.previous()
        elif action == "add" and request.POST and request.POST.has_key('path'):
            m.add(request.POST['path'])
        elif action == "clear":
            m.clear()
        elif action == "replace":
            m.clear()
            m.add(request.POST['path'])
            m.play()
        elif action == "deleteid" and songid:
            m.deleteid(int(songid))
        elif action == "playid" and songid:
            m.playid(int(songid))
        elif action == "volume_up":
            status = m.status()
            volume = int(status.volume)
            volume_new = volume + 5
            m.setvol(volume_new)
        elif action == "volume_down":
            status = m.status()
            volume = int(status.volume)
            volume_new = volume - 5
            m.setvol(volume_new)

        if request.POST and request.POST.has_key('next'):
            next= request.POST['next']
            return HttpResponseRedirect(next)

    return HttpResponseRedirect('/playlist/')
示例#19
0
文件: tmpc.py 项目: gaving/tmpc
    def show_notification(self, timeout=True):
        if self.track.has_key("artist") and self.track.has_key("title"):
            artist = self.track['artist'].replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;') 
            title = self.track['title'].replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;') 
            self.artist_url = LAST_FM['ARTIST_URL'] + artist
            self.title_url = LAST_FM['ARTIST_URL'] + artist + LAST_FM['TITLE_URL'] + title
            artist = "<a href='%s'>%s</a>" % (urllib.quote(self.artist_url), artist)
            title = "<a href='%s'>%s</a>" % (urllib.quote(self.title_url), title)
            markup = "%s - %s" % (artist, title)
#            if self.track.has_key("album"):
#                album = self.track['album'].replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;') 
#                markup += " (.. %s)" % album
        else:
            markup = self.track['file']

        if self.n:
            self.n.close()

        # Create new popup with the image returned 
        self.n = pynotify.Notification(self.get_status(), markup, self.get_image())
        x, y = self.box.window.get_origin()


        time_left = None
        try:
            # Work out the time left of the track and use it as the timeout
            track_length = mpdclient2.connect().status()['time'].split(':')
            time_left = (int(track_length[1]) - int(track_length[0])) * 1000
        except KeyError:
            pass

        self.n.set_timeout(timeout and 3000 or time_left or 3000)
        
        self.n.add_action("media-play", "Queue Album", self.on_queue_album_cb)
        self.n.add_action("properties", "Lyrics", self.on_lyrics_clicked_cb)
        self.n.add_action("edit", "Edit Tag", self.on_edit_clicked_cb)

        self.n.set_hint("x", x)
        self.n.set_hint("y", y)

        if not self.n.show():
            debug("Error: Failed to send notification")
示例#20
0
  def __init__(self, config):
    streamer_config = dict(config.items('streamer'))

    if streamer_config.has_key('mpd'):
      mpd = config.get('streamer', 'mpd')
      del streamer_config['mpd']
    else:
      mpd = 'mpd'

    self._mpd_runner = MpdRunner(streamer_config, mpd_bin=mpd)
    self._mpd_runner.run()
    atexit.register(self._mpd_runner.stop)
    self._client = mpdclient2.connect(port=self._mpd_runner.port,
                                      password=self._mpd_runner.password)

    # Clear any existing playlist
    self._last_track_id = -1
    self._client.clear()
    self._client.random(0)
    self._client.repeat(0)
    self._client.crossfade(2)
示例#21
0
def get_info():
    check_running = commands.getoutput("ps aux")
    check_running = check_running.split("\n")
    for line in check_running:
        if "mocp" in line:
            return commands.getoutput("mocp -Q %artist"),commands.getoutput("mocp -Q %album"),commands.getoutput("mocp -Q %song")
        if "rhythmbox" in line:
            return commands.getoutput("rhythmbox-client --print-playing-format %ta"),commands.getoutput("rhythmbox-client --print-playing-format %at"),commands.getoutput("rhythmbox-client --print-playing-format %tt")
        if "mpd" in line:
            try:
                import mpdclient2
            except:
                print "please install python-mpdclient"
                raise SystemExit()
            mpd = mpdclient2.connect()
            song = mpd.currentsong()
            if song:
                return song.artist, song.album, song.title
            else:
                return "","",""
    return "","",""
示例#22
0
文件: tmpc.py 项目: gaving/tmpc
    def check_for_change(self):
        conn = mpdclient2.connect()
        track = conn.currentsong()
        conn_status = conn.status()
        status = {
                'state' : conn_status['state'],
                'random' : int(conn_status['random']),
                'repeat' : int(conn_status['repeat']),
                'updating' : int(conn_status.has_key('updating_db'))
        }
        if track != self.track or status != self.status:
            self.track = track
            self.status = status

            # Show popups only on a play status change, nothing else!
            if status['state'] == "play" and not status['updating']:
                self.add_recent_track()
                self.show_notification()

            self.update_tray()
            debug(self.track)

        return True
示例#23
0
    def get_cover_path(self):
                artist = self.get_artist()
                album = self.get_album()
                filename = os.path.expanduser("~/.covers/" + artist + "-" + album + ".jpg")
                if os.path.isfile(filename):
                        return filename

		try:
			t = mpdclient2.connect().currentsong().file
			t = t.replace('file://','')
			t = t.split('/')
			basePath = ''
			for l in t:
				if l.find('.') == -1:
					basePath = basePath + l +'/'
		
			names = ['Album', 'Cover', 'Folde']
			for x in os.listdir(basePath):
				if os.path.splitext(x)[1] in [".jpg", ".png"] and (x.capitalize()[:5] in names):
					coverFile = basePath + x
					return coverFile
		except: return ''
                return ''
示例#24
0
文件: views.py 项目: blenderbox/bagel
def playlist(request):
    context = {"next": request.path, "page": "playlist", "media_url": settings.MEDIA_URL}
    try:
        m = mpdclient2.connect()
    except socket.error:
        m = False

    if m:
        playlistinfo = m.playlistinfo()
        currentsong = m.currentsong()
        status = m.status()
        if hasattr(currentsong, "artist") and hasattr(status, "time"):
            time = get_track_time(status.time)
            context["time"] = time
            context["currentsong"] = currentsong

        context["playlist"] = playlistinfo
        context["status"] = status

    else:
        context = {"errors": ["could not connect to server"]}

    return render_to_response("babik/playlist.html", context)
示例#25
0
        y = tmpy
    except ValueError:
        pass
    return x, y
 
def sort(x, y):
    for key in order:
        if x.has_key(key) and y.has_key(key):
            xitem = x[key].lower()
            yitem = y[key].lower()
            if key == "track":
                xitem, yitem = get_tracks(xitem, yitem)
            diff = cmp(xitem, yitem)
        else:
            diff = cmp(x.has_key(key), y.has_key(key))
        if diff != 0:
            return diff
    return 0
 
 
conn = mpdclient2.connect()
playlist = conn.playlistinfo()
playlist.sort(sort)
conn = mpdclient2.connect()
conn.clear()
for song in playlist:
    conn.add(song.file)
 
 
# vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=79:
示例#26
0
#!/usr/bin/env python

# usage: ./lyrics.py "Frank Sinatra" "New York"

import sys
import mpdclient2
from SOAPpy import WSDL
from optparse import OptionParser

parser = OptionParser(usage="%prog artist title", version="0.1",
                      description="Grab Lyrics")
options, args = parser.parse_args()

proxy = WSDL.Proxy('http://lyricwiki.org/server.php?wsdl')

if len(args) < 2:
    track = mpdclient2.connect().currentsong()
    artist = track['artist']
    title = track['title']
else:
    artist = sys.argv[1]
    title = sys.argv[2]

if proxy.checkSongExists(artist, title):
    info = proxy.getSong(artist, title)
    print info['lyrics']
else:
    print "No song found :("

# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
示例#27
0
文件: tmpc.py 项目: gaving/tmpc
    def create_tray(self):
        self.menu = gtk.Menu()
        
        item = gtk.ImageMenuItem(stock_id=gtk.STOCK_MEDIA_NEXT)
        item.connect("activate", lambda *args: mpdclient2.connect().next())
        self.menu.append(item)
        item = gtk.ImageMenuItem(stock_id=gtk.STOCK_MEDIA_PREVIOUS)
        item.connect("activate", lambda *args: mpdclient2.connect().previous())
        self.menu.append(item)
        
        self.menu.append(gtk.SeparatorMenuItem())
        
        if self.lyrics.is_enabled:
            lyrics = gtk.ImageMenuItem("Lyrics")
            img = gtk.Image()
            img.set_from_icon_name('audio-input-microphone', gtk.ICON_SIZE_MENU)
            lyrics.set_image(img)
            lyrics.connect("activate", lambda *args: self.on_lyrics_clicked_cb())
            self.menu.append(lyrics)

        item = gtk.ImageMenuItem(stock_id=gtk.STOCK_EDIT)
        item.connect("activate", lambda *args: self.on_edit_clicked_cb())
        self.menu.append(item)
        
        self.menu.append(gtk.SeparatorMenuItem())
        
        self.recent = gtk.ImageMenuItem("Recent tracks")
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_BUTTON)
        self.recent.set_image(img)
        self.menu.append(self.recent)
        self.recent_tracks_menu = gtk.Menu()
        self.recent.set_submenu(self.recent_tracks_menu)
        
        self.album = gtk.ImageMenuItem("Current Album")
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_BUTTON)
        self.album.set_image(img)
        self.menu.append(self.album)
        self.current_album_menu = gtk.Menu()
        self.album.set_submenu(self.current_album_menu)
       
        if self.lastfm.is_enabled:
            self.friends = gtk.ImageMenuItem("Friends")
            img = gtk.Image()
            img.set_from_stock(gtk.STOCK_ORIENTATION_PORTRAIT, gtk.ICON_SIZE_BUTTON)
            self.friends.set_image(img)
            self.menu.append(self.friends)
            self.friends_menu = gtk.Menu()
            self.friends.set_submenu(self.friends_menu)
      
            for friend in self.lastfm.get_friends_names():
                item = gtk.MenuItem(friend)
                menus = {
                        'item' : item,
                        'submenu' : gtk.Menu()
                }
                self.friends_menus[friend] = menus
                self.friends_menu.append(item)
                item.set_submenu(self.friends_menus[friend]['submenu'])

        self.menu.append(gtk.SeparatorMenuItem())
        
        item = gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT)
        item.connect("activate", gtk.main_quit)
        self.menu.append(item)
        
        self.menu.show_all()

        # FIXME: Update this to the latest way of doing it
        self.tray = egg.trayicon.TrayIcon("TrayIcon")
        self.box = gtk.EventBox()
        self.image = gtk.Image()
        self.box.add(self.image)
        self.tray.add(self.box)
        self.tray.show_all()

        self.box.connect("button-press-event", self.on_tray_clicked_cb)
        self.box.connect("scroll-event", self.on_tray_scroll_cb)
        self.box.connect("enter-notify-event", self.on_popup_open_cb)
        self.box.connect("leave-notify-event", self.on_popup_close_cb)
示例#28
0
 def readPlaylist(self):
     self.playlist = mpdclient2.connect().playlistinfo()
示例#29
0
文件: tmpc.py 项目: gaving/tmpc
    def __init__(self):
        if not pynotify.init("Init"):
            debug("Error: Failed to initialize pynotify.")
            sys.exit(1)

        parser = OptionParser(usage="%prog [options]", version="0.1",
                              description="Tray based notifier for MPD.")
        parser.add_option('-v', dest='verbosity', help='Display debugging output', 
                action="store_const", const=1)
        parser.add_option('-d', '--disable-lastfm', dest='lastfm', 
                help='Disable lastfm functionality', action="store_false")
        parser.add_option('-l', '--disable-lyrics', dest='lyrics', 
                help='Disable lyrics functionality', action="store_false")
        parser.set_defaults(**DEFAULTS)
        (option_obj, args) = parser.parse_args()
        
        options = {}
        options['verbosity'] = option_obj.verbosity
        options['lastfm'] = option_obj.lastfm
        options['lyrics'] = option_obj.lyrics

        # FIXME: Ewww.
        global DEBUG_LVL
        DEBUG_LVL = options['verbosity']

        print options

        self.track = {}
        self.artist_url = None
        self.title_url = None
        self.uri = None
        self.tray = None
        
        self.menu = None
        self.buttons = None
        self.box = None
        self.n = None

        self.recent_tracks = []
        self.recent_tracks_menu = None
        self.friends_menus = {}
       
        # Initialize 'modules'
        self.lastfm = Lastfm()
        self.lyrics = Lyrics()
            
        debug("* Populating playlist...")
        timing.start()
        self.playlist = mpdclient2.connect().playlistinfo()
        timing.finish()
        debug("..done. (%d seconds)" % timing.seconds())
        
        if options['lastfm']:
            debug("* Enabling last.fm functionality")
            self.lastfm.enable()

            debug("* Fetching recently played tracks")
            self.recent_tracks = self.lastfm.fetch_recent_tracks(LAST_FM['USERNAME'])

            debug("* Starting friend grabs every minute")
            gobject.timeout_add(60000, self.lastfm.sched_friends_data)
        
        if options['lyrics']:
            debug("* Enabling lyrics functionality")
            self.lyrics.enable()

        self.create_tray()
            
        # Check for track change every second
        gobject.timeout_add(1000, self.check_for_change)
示例#30
0
文件: tmpc.py 项目: gaving/tmpc
 def get_current_album_tracks(self):
     try:
         return mpdclient2.connect().search('album', self.track['album'])
     except KeyError:
         pass
示例#31
0
 def previous(self):
     mpdclient2.connect().previous()
示例#32
0

strip_expr = compile(u'(%s)/' % ur'|'.join(strip_paths))

def get_status(connection):
    """Get playing state and song information.
    
    @return: Play state and song information.
    @rtype: C{dict}
    @param connection: mpd connection to use.
    @type connection: C{mpdclient2.mpd_connection}
    """
    songinfo = {}
    songinfo['state'] = state_map[connection.status()['state']]
    song = connection.currentsong()
    songinfo['song'] = \
        u' - '.join([unicode(song[f])
        for f in fields
            if song.has_key(f)]) \
            or unicode(strip_expr.sub(u'',
                    splitext(unicode(song['file']))[0]).replace(sep, u' - '))
    return songinfo

if __name__ == '__main__':
    import locale, codecs
    from mpdclient2 import connect
    enc = locale.getpreferredencoding()
    sys.stdout = codecs.getwriter(enc)(sys.__stdout__)
    format = u'♫ %(state)s: %(song)s'
    print format % get_status(connect())
示例#33
0
文件: tmpc.py 项目: gaving/tmpc
 def on_recent_track_clicked_cb(self, widget, track):
     mpdclient2.connect().playid(int(track["id"]))
     debug("* Playing recent track with id: %d" % int(track["id"]))
示例#34
0
import mpdclient2

argv = sys.argv

# The default port for MPD is 6600.  If for some reason you have MPD
# running on a different port, change this setting.
mpdPort = 6600

# determin path to this file
# my_path = sys.modules[__name__].__file__
# if this fails for some reason, just set it manually.
# Eg.
my_path = "/home/YOURUSERNAME/.pekwm/scripts/mpd.py"

try:
    connect = mpdclient2.connect(port=mpdPort)
except socket.error:
    # If MPD is not running.
    if len(argv) > 1 and argv[1] == 'start':
        os.execl('/usr/bin/mpd', '$HOME/.mpdconf')
    else:
        print "Dynamic {"
        print "SubMenu = \"MPD\" {"
        print "Entry = \"%s\" { Actions = \"Exec my_path \"%s\" &\" }" % (
            'MPD is not running  [start]', 'start')
        print "}"
        print "}"

else:  # part of connect try block

    song = connect.currentsong()
示例#35
0
import mpdclient2
m = mpdclient2.connect()

print m.status()  # -> prints status object

outputs = m.outputs()

print 'i got %d output(s)' % len(outputs)

for output in outputs:
    print "here's an output"
    print "  id:", output.outputid
    print "  name:", output.outputname
    print "  enabled:", ('no', 'yes')[int(output.outputenabled)]

######

print "let's find some beck songs"

beck_songs = m.find("artist", "beck")

print 'i got %d beck song(s)' % len(beck_songs)

if len(beck_songs) > 5:
    print ".. but let's just look at the first 5"

for i, song in enumerate(beck_songs[:5]):
    print "%4d. %s -- %s" % (i + 1, song.album, song.title)

print m.currentsong()
示例#36
0
 def is_playing(self):
     status = mpdclient2.connect().status()
     return (status.state != 'stop')
示例#37
0
 def next(self):
     mpdclient2.connect().next()
示例#38
0
 def get_artist(self):
     song = mpdclient2.connect().currentsong()
     return song.artist
示例#39
0
 def getCurrentTrack(self):
     conn = mpdclient2.connect()
     return conn.currentsong()
示例#40
0
	def connect(self):
		self.playerAPI = mpdclient2.connect()
示例#41
0
 def get_title(self):
     song = mpdclient2.connect().currentsong()
     return song.title
示例#42
0
 def connect(self):
     self.mpd = mpdclient2.connect()
     bemused.logger.log("Connected to MPD server at %s:%s" % (self.mpd.talker.host,
                                                              self.mpd.talker.port))
示例#43
0
文件: ob-mpd.py 项目: benf/dotfiles
# if this fails for some reason, just set it manually.
# Eg.
# my_path = "~/.config/openbox/scripts/ob-mpd.py"


separator = "<separator />"
info = """<item label="%s" />"""
action = (
    """<item label="%s"><action name="Execute">""" """<execute>MY_PATH %s</execute>""" """</action></item>"""
).replace("MY_PATH", my_path)
menu = """<menu id="%s" label="%s">"""
menu_end = """</menu>"""


try:
    connect = mpdclient2.connect(port=mpdPort)
except socket.error:
    # If MPD is not running.
    if len(argv) > 1 and argv[1] == "start":
        os.execl("/usr/bin/mpd", "$HOME/.mpdconf")
    else:
        print ('<?xml version="1.0" encoding="UTF-8"?>' "<openbox_pipe_menu>")
        print action % ("MPD is not running  [start]", "start")
        print "</openbox_pipe_menu>"

else:  # part of connect try block

    song = connect.currentsong()
    stats = connect.stats()
    status = connect.status()
示例#44
0
 def get_album(self):
     song = mpdclient2.connect().currentsong()
     return song.album