Ejemplo n.º 1
0
def test_config_man():
    config.setConfigFolder("./")
    assert config.getConfigFolder() == "./" 

    config.setProperty("test-property", "test-value")
    assert config.getProperty("test-property") == "test-value"
    config.deleteConfigFile()
Ejemplo n.º 2
0
def extractArtwork():
    config.setConfigFolder('../config/')
    tracks = load()
    from mutagen import File
    from mutagen.flac import FLAC
    import os

    for track in tracks:
        print track
        dirname = os.path.dirname(track.filePath)
        coverFullname = dirname + "/" + "cover.jpg"

        _file = File(track.filePath) # mutagen can automatically detect format and type of tags
        artwork = None
        try:
            artwork = _file.tags['APIC:'].data # access APIC frame and grab the image
        except KeyError as e:
            pass
        if not artwork:
            try:
                if track.filePath.endswith(".flac"):
                    _file = FLAC(track.filePath)
                    if len(_file.pictures) > 0:
                        artwork = _file.pictures[0].data
            except KeyError as e:
                pass
        if artwork:
            if not os.path.isfile(coverFullname):
                print "will write {0}".format(coverFullname)
                with open(coverFullname, 'wb') as f:
                    f.write(artwork) # write artwork to new image
Ejemplo n.º 3
0
def reIndexArt():
    import content, config
    config.setConfigFolder('../config/')
    indexer = MusicIndexer()
    tracks = content.load()
    for track in tracks:
        track.albumCoverPath = indexer._getAlbumCover(os.path.dirname(track.filePath)).encode("utf-8")
    content.save(tracks)
Ejemplo n.º 4
0
    def setCapabilities(self, capabilities):
        self.capabilities = capabilities


def testPresenceBroadcaster():
    thisDevice = Device(url="localhost:5000", visibleName="test-device")
    bc = DevicePresenceBroadcaster(thisDevice, delayBetweenBroadcastsInSec=1)
    watcher = DeviceWatcher()
    watcher.start()
    bc.start()
    time.sleep(5)
    bc.stop()
    watcher.stop()

if __name__ == '__main__':
    config.setConfigFolder('../config/')
    testPresenceBroadcaster()
    #man = DeviceManager()
   # man.handleDeviceNotificationReceived("rpi-yam","192.168.1.127:5005")
    #print man.printRegisteredDevices()

def startPresenceBroadcaster():
    from devices import Device
    thisDevice = Device("rpi")
    PRESENCE_BROADCASTER = DevicePresenceBroadcaster(thisDevice)
    PRESENCE_BROADCASTER.start()

def stopPresenceBroadcaster():
    if PRESENCE_BROADCASTER:
        PRESENCE_BROADCASTER.stop()