Ejemplo n.º 1
0
    def rename (self, songs):
        # TODO: parametrize the main music colleciton
        mainColl= self.collaggr.collections[0]
        base= mainColl.path
        d= QDir ()

        for song in songs:
            dstPath= self.songPath (base, song)
            dstDir= os.path.dirname (dstPath)
            # TODO: QtDir is not net transp. try to make sub jobs creating the missing path
            if d.mkpath (dstDir):
                # HINT: KUrl because KIO.* use KUrl
                # src= KUrl (song.filepath)
                src= KUrl (utils.path2qurl (song.filepath))
                # BUG: Renamer.rename()
                # PyQt4.QtCore.QUrl(u'file:///home/mdione/media/music/new/bandidos rurales/05 - uruguay, uruguay.mp3') ->
                # PyQt4.QtCore.QUrl(u'file:///home/mdione/media/music/Le\xf3n Gieco/2001 - Bandidos rurales/05 - Uruguay, Uruguay.mp3')
                #                                                       ^^^^
                dst= KUrl (dstPath)
                logger.info ("Renamer.rename()", src, "->", dst)

                # TODO: do not launch them all in parallel
                job= KIO.file_move (src, dst)
                # TODO: emit a finished.

                # print "Renamer.rename()", job
                job.result.connect (self.jobFinished)
                # print "Renamer.rename(): connected"
                self.jobs.append (job)
                # print "Renamer.rename(): next!"
            else:
                logger.info ("Renamer.rename(): failed to create", dstDir, ", skipping", dstPath)
Ejemplo n.º 2
0
 def queueNext (self):
     logger.debug ("queueing next!")
     self.playlist.next ()
     self.filepath= self.playlist.filepath
     logger.debug ("--> queueing next!", self.filepath)
     url= utils.path2qurl (self.filepath)
     source= Phonon.MediaSource (url)
     self.media.enqueue (source)
Ejemplo n.º 3
0
def getMimeType (filepath):
    mimetype, accuracy= KMimeType.findByFileContent (filepath)
    if accuracy<50:
        # try harder?
        # BUG?: (in KMimeType) gets confused by filenames with #'s
        # mimetype, accuracy= KMimeType.findByUrl (KUrl (utils.path2qurl (filepath)), 0, False, True)
        mimetype, accuracy= KMimeType.findByUrl (KUrl (utils.path2qurl (filepath)))

    return str (mimetype.name ())
Ejemplo n.º 4
0
    def play (self, song=None):
        if self.state==Player.PAUSED:
            # let pause() handle unpausing...
            self.pause ()
        else:
            self.state= Player.PLAYING
            # the QPushButton.clicked() emits a bool,
            # and it's False on normal (non-checkable) buttons
            # it's not false, it's 0, which is indistinguishable from play(0)
            # also, 0!=False is False?
            # >>> 0!=False
            # False
            if song is not None:
                logger.debug ("player.play()", song)
                self.playlist.jumpToSong (song)

            self.filepath= self.playlist.filepath

            logger.debug ("playing", self.filepath)
            url= utils.path2qurl (self.filepath)
            self.media.setCurrentSource (Phonon.MediaSource (url))
            self.media.play ()