Quantcast
Channel: The Echo Nest Developer Forum
Viewing all articles
Browse latest Browse all 1582

Hotttest songs without duplicates

$
0
0

Aquarius - Yes, the duplicates are a pain in the neck. We are working on an overarching solution. Until then, there are a couple of options for you to generate lists of hot songs with no dups.

One way, is, as you suggest, to use the playlist API. The best option for your use case is to create a playlist of genre-radio type. Use either the 'pop' genre or one of our pseudo-genres:'hot', 'current' or 'discovery'. Here's the call:

http://developer.echonest.com/api/v4/playlist/static?api_key=YOUR_API_KEY&type=genre-radio&genre=hot

You can also easily filter out song duplicates using the technique in this demo:

http://static.echonest.com/demo/songhottt/song-hottt.html

This approach takes advantage of the fact that duplicate songs almost always share the same hotttnesss. This app creates a song hash function that consists of the artist id and the song hotttnesss and eliminates dups by simply keeping a set of the these hashes and dropping any new songs that already have a hash in the set.

Here's the salient code:

var dups = {};      // used to eliminate dup songs

function isGoodSong(song) {
    var hash = getDupHash(song); 
    if (! (hash in dups)) {
        dups[hash] = song;
        return true;
    } else {
         return false;
    }
}

function getDupHash(song) {
    return song.artist_id + song.song_hotttnesss;
}

Hope this helps.

Paul


Viewing all articles
Browse latest Browse all 1582

Trending Articles