Exemplo n.º 1
0
def get_cur_artist(items):
    """Given a sequence of items, returns the current artist and
    artist ID that is most popular among the fingerprinted metadata
    for the tracks.
    """
    # Get "fingerprinted" artists for each track.
    artists = []
    artist_ids = []
    for item in items:
        last_data = match(item.path)
        if last_data:
            artists.append(last_data['artist'])
            if last_data['artist_mbid']:
                artist_ids.append(last_data['artist_mbid'])

    # Vote on the most popular artist.
    artist, _ = autotag._plurality(artists)
    artist_id, _ = autotag._plurality(artist_ids)

    return artist, artist_id
Exemplo n.º 2
0
def get_cur_artist(items):
    """Given a sequence of items, returns the current artist and
    artist ID that is most popular among the fingerprinted metadata
    for the tracks.
    """
    # Get "fingerprinted" artists for each track.
    artists = []
    artist_ids = []
    for item in items:
        last_data = match(item.path)
        if last_data:
            artists.append(last_data['artist'])
            if last_data['artist_mbid']:
                artist_ids.append(last_data['artist_mbid'])

    # Vote on the most popular artist.
    artist, _ = autotag._plurality(artists)
    artist_id, _ = autotag._plurality(artist_ids)

    return artist, artist_id
Exemplo n.º 3
0
 def test_plurality_conflict(self):
     objs = [1, 1, 2, 2, 3]
     obj = autotag._plurality(objs)
     self.assert_(obj in (1, 2))
Exemplo n.º 4
0
 def test_plurality_near_consensus(self):
     objs = [1, 1, 2, 1]
     obj = autotag._plurality(objs)
     self.assertEqual(obj, 1)
Exemplo n.º 5
0
 def test_plurality_conflict(self):
     objs = [1, 1, 2, 2, 3]
     obj, consensus = autotag._plurality(objs)
     self.assert_(obj in (1, 2))
     self.assertFalse(consensus)
Exemplo n.º 6
0
 def test_plurality_consensus(self):
     objs = [1, 1, 1, 1]
     obj, consensus = autotag._plurality(objs)
     self.assertEqual(obj, 1)
     self.assertTrue(consensus)
Exemplo n.º 7
0
 def test_plurality_conflict(self):
     objs = [1, 1, 2, 2, 3]
     obj, consensus = autotag._plurality(objs)
     self.assert_(obj in (1, 2))
     self.assertFalse(consensus)
Exemplo n.º 8
0
 def test_plurality_near_consensus(self):
     objs = [1, 1, 2, 1]
     obj, consensus = autotag._plurality(objs)
     self.assertEqual(obj, 1)
     self.assertFalse(consensus)