alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
317 stars 97 forks source link

How to snag a song to playlist and become a fan? #45

Closed Katazui closed 12 years ago

Katazui commented 12 years ago

How can the bot snag every song a person plays and adds it to their playlist? And become that persons fan when they play at the same time?

jlbruno commented 12 years ago

You'd have to run a function every time the "new song" event is fired. Check the data returned from the event, grab the userid of the current DJ, and compare to the user you want to grab songs from. If it's the same user, add the song to your playlist.

alaingilbert commented 12 years ago
var Bot = require('ttapi');
var bot = new Bot('auth+live+xxx', 'xxx', 'xxx');

bot.on('newsong', function (data) {
   bot.snag();
   bot.playlistAdd(data.room.metadata.current_song._id);
   bot.becomeFan(data.room.metadata.current_dj);
});

Something like this should work. (I didn't test the code)

Katazui commented 12 years ago

Yay, it works. Thanks.