Created
December 26, 2008 04:08
-
-
Save fitoria/40003 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# This file is part of emesene. | |
# | |
# Emesene is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# emesene is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with emesene; if not, write to the Free Software | |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
# | |
# CurrentSong plugin extension for Amarok2 | |
# Adolfo J. Fitoria E. <[email protected]> | |
VERSION = '0.3' | |
IFACE_NAME = 'org.mpris.amarok' | |
IFACE_PATH = '/TrackList' | |
import os | |
import dbus | |
import CurrentSong | |
error = False | |
class Amarok2( CurrentSong.DbusBase ): | |
'''Amarok2 CurrentSong Plugin.''' | |
def __init__(self): | |
CurrentSong.DbusBase.__init__( self, IFACE_NAME, self.setInterface ) | |
try: | |
self.iface | |
except: | |
self.iface = None | |
self.playingNow = '' | |
def setInterface( self ): | |
self.iface = self.bus.get_object(IFACE_NAME, IFACE_PATH) | |
def isPlaying( self ): | |
return True | |
#if self.iface: | |
# return self.iface.Status() == "playing" | |
def getStatus(self): | |
'''Check if everything is ok to start the plugin''' | |
if os.name != 'posic': | |
return (False, _('This plugin only works in posix systems')) | |
if not self.iface: | |
return (False, _('You don\'t have dbus.')) | |
return (True, 'Ok') | |
def getCurrentSong(self): | |
if self.iface: | |
if self.isPlaying(): | |
current_track = self.iface.GetCurrentTrack() | |
current_song = self.iface.GetMetadata(current_track) | |
self.artist = current_song['artist'] | |
self.title = current_song['title'] | |
self.album = current_song['album'] | |
#self.filename = current_song['filename'] | |
else: | |
self.artist = '' | |
self.title = '' | |
self.artist = '' | |
self.filename = '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment