示例#1
0
        def callback(success, artist, title, song_id, path):
            if success:
                try:
                    # read mp3
                    mf = Player.open(path)
                    length = mf.total_time()

                    sql = 'UPDATE songs SET length = ?, bitrate = ?, samplerate = ?, processed = 1 WHERE id = ?'
                    self.db.execute(sql, length, mf.bitrate() / 1000, mf.samplerate(), song_id)

                    # update lists
                    self.player.playlist.append(song_id, artist, title, length)
                    self.application.wso.new(song_id)

                    # update free space
                    self.application.disk = self.player.free_space()
                    self.application.wso.disk(self.application.disk)

                    message = u'Song "%s \u2014 %s" was added to the playlist' % (artist, title)
                    return self.alert(message, self.ALERT_SUCCESS)
                except: pass

            self.db.execute('DELETE FROM songs WHERE id = ?', song_id)
            self.alert(u'File for song "%s \u2014 %s" is broken' % (artist, title))