Example #1
0
def albumsMostPlayed():
    grouped = __groupItemsByKey__(itunesCollection, itunes.KEY_ALBUM)
    playTimes = __aggregatePlayTimesForGroups__(grouped)
    sortedByPlayTime = sorted(playTimes, key = operator.itemgetter(1))
    for item in sortedByPlayTime:
        hhmmss = timeutil.millisToHHMMSS(item[1])
        print LABEL_ROW_TEMPLATE.format(item[0], hhmmss[0], hhmmss[1], hhmmss[2])
Example #2
0
def totalPlayTime():
    totalPlayTime = 0
    for itunesTrackData in itunesCollection.find({itunes.KEY_PLAY_COUNT : {'$gt':0}}):
        trackPlayTime = itunesTrackData[itunes.KEY_TOTAL_TIME] * itunesTrackData[itunes.KEY_PLAY_COUNT]
        totalPlayTime += trackPlayTime
    totalHhmmss = timeutil.millisToHHMMSS(totalPlayTime)
    print LABEL_ROW_TEMPLATE.format('TOTAL', totalHhmmss[0], totalHhmmss[1], totalHhmmss[2])