Пример #1
0
    def updateSongRecord(self,song,newtime=-1):
        # update the given song because it has just finished playing
        # update the lengths if there is a discrepancy using newtime as the new length
        if song == None:
            debug("None Song Passed to updateSongRecord")
            return
        
        if newtime >= 0:
            if (newtime < song[MpMusic.LENGTH]-1 or newtime > song[MpMusic.LENGTH]+1) and newtime > 1 :
                MpGlobal.Window.emit(SIGNAL("DEBUG_MESSAGE"),"%s : OldTime: %d NewTime: %d"%(song[MpMusic.TITLE],song[MpMusic.LENGTH],newtime))  
                song[MpMusic.LENGTH] = newtime
            
        dt = DateTime()
        days_elapsed = dt.daysElapsed(song[MpMusic.DATESTAMP]) # number of days since the date stamp

        
        song[MpMusic.DATESTAMP] = dt.currentDateTime();
        song[MpMusic.DATEVALUE] = DateTime.now();
        
        song.updateFrequency(days_elapsed)

        song[MpMusic.PLAYCOUNT] += 1 
        
        song.calcBaseScore();
        song.calcScore(MpGlobal.Histogram);
        
        song.update();
        # refill the library, if it was in view, its text needs to be updated
        #Player_set_unsaved()
        MpGlobal.Window.emit(SIGNAL("QUEUE_FUNCTION"),Player_set_unsaved)
        MpGlobal.Window.emit(SIGNAL("FILL_LIBRARY"))