Example #1
0
def show_stats(lib, query):
    """Shows some statistics about the matched items."""
    items = lib.items(query)

    total_size = 0
    total_time = 0.0
    total_items = 0
    artists = set()
    albums = set()

    for item in items:
        #fixme This is approximate, so people might complain that
        # this total size doesn't match "du -sh". Could fix this
        # by putting total file size in the database.
        total_size += int(item.length * item.bitrate / 8)
        total_time += item.length
        total_items += 1
        artists.add(item.artist)
        albums.add(item.album)

    print_("""Tracks: %i
Total time: %s
Total size: %s
Artists: %i
Albums: %i""" % (total_items, ui.human_seconds(total_time),
                 ui.human_bytes(total_size), len(artists), len(albums)))
Example #2
0
def show_stats(lib, query):
    """Shows some statistics about the matched items."""
    items = lib.items(query)

    total_size = 0
    total_time = 0.0
    total_items = 0
    artists = set()
    albums = set()

    for item in items:
        #fixme This is approximate, so people might complain that
        # this total size doesn't match "du -sh". Could fix this
        # by putting total file size in the database.
        total_size += int(item.length * item.bitrate / 8)
        total_time += item.length
        total_items += 1
        artists.add(item.artist)
        albums.add(item.album)

    print_("""Tracks: %i
Total time: %s
Total size: %s
Artists: %i
Albums: %i""" % (
        total_items,
        ui.human_seconds(total_time),
        ui.human_bytes(total_size),
        len(artists), len(albums)
    ))
Example #3
0
def show_stats(lib, query, exact):
    """Shows some statistics about the matched items."""
    items = lib.items(query)

    total_size = 0
    total_time = 0.0
    total_items = 0
    artists = set()
    albums = set()

    for item in items:
        if exact:
            total_size += os.path.getsize(item.path)
        else:
            total_size += int(item.length * item.bitrate / 8)
        total_time += item.length
        total_items += 1
        artists.add(item.artist)
        albums.add(item.album)

    size_str = '' + ui.human_bytes(total_size)
    if exact:
        size_str += ' ({0} bytes)'.format(total_size)

    print_("""Tracks: {0}
Total time: {1} ({2:.2f} seconds)
Total size: {3}
Artists: {4}
Albums: {5}""".format(total_items, ui.human_seconds(total_time), total_time,
                      size_str, len(artists), len(albums)))
Example #4
0
def show_stats(lib, query, exact):
    """Shows some statistics about the matched items."""
    items = lib.items(query)

    total_size = 0
    total_time = 0.0
    total_items = 0
    artists = set()
    albums = set()

    for item in items:
        if exact:
            total_size += os.path.getsize(item.path)
        else:
            total_size += int(item.length * item.bitrate / 8)
        total_time += item.length
        total_items += 1
        artists.add(item.artist)
        albums.add(item.album)

    size_str = '' + ui.human_bytes(total_size)
    if exact:
        size_str += ' ({0} bytes)'.format(total_size)

    print_("""Tracks: {0}
Total time: {1} ({2:.2f} seconds)
Total size: {3}
Artists: {4}
Albums: {5}""".format(total_items, ui.human_seconds(total_time), total_time,
                      size_str, len(artists), len(albums)))
Example #5
0
    def update_stats(self):
        items = self.library.items()

        total_size = 0
        total_time = 0.0
        total_items = 0
        artists = set()
        albums = set()
        album_artists = set()

        for item in items:
            total_size += int(item.length * item.bitrate / 8)
            total_time += item.length
            total_items += 1
            artists.add(item.artist)
            album_artists.add(item.albumartist)
            if item.album_id:
                albums.add(item.album_id)

        size_str = human_bytes(total_size)
        time_str = human_seconds(total_time)
        self.stats["count"] = total_items
        self.stats["time"] = time_str
        self.stats["size"] = size_str
        self.stats["artists"] = len(artists)
        self.stats["albums"] = len(albums)
        self.stats["album_artists"] = len(album_artists)
Example #6
0
 def test_human_seconds(self):
     tests = [
         (0, '0.0 seconds'),
         (30, '30.0 seconds'),
         (60, '1.0 minutes'),
         (90, '1.5 minutes'),
         (125, '2.1 minutes'),
         (3600, '1.0 hours'),
         (86400, '1.0 days'),
         (604800, '1.0 weeks'),
         (31449600, '1.0 years'),
         (314496000, '1.0 decades'),
     ]
     for i, h in tests:
         self.assertEqual(h, ui.human_seconds(i))
Example #7
0
 def test_human_seconds(self):
     tests = [
         (0, '0.0 seconds'),
         (30, '30.0 seconds'),
         (60, '1.0 minutes'),
         (90, '1.5 minutes'),
         (125, '2.1 minutes'),
         (3600, '1.0 hours'),
         (86400, '1.0 days'),
         (604800, '1.0 weeks'),
         (31449600, '1.0 years'),
         (314496000, '1.0 decades'),
     ]
     for i, h in tests:
         self.assertEqual(h, ui.human_seconds(i))