alaingilbert / Turntable-API

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

Access room.directory_rooms API #130

Closed josephwegner closed 11 years ago

josephwegner commented 11 years ago

The API has to be accessed over HTTP, which I know is against the grain of everything you are already doing, but it seemed worth it to me. I couldn't find a way to access it via websockets.

bboe commented 11 years ago

How is this different from listRooms?

MikeWills commented 11 years ago

I was curious about this as well.

Izzmo commented 11 years ago

You sure you guys don't mean directory_graph and not list_rooms? directory_graph seems to be the one that's closer aligned to this.

josephwegner commented 11 years ago

@Izzmo This would be more in line with listRooms - it has no functionality based on where your friends are.

@MikeWills @bboe Perhaps I'm reading the docs wrong, but I believe that listRooms doesn't have any ability to do filters, sorts or limits. The functionality of directory_rooms lets you sort by things like # of listeners, or filter by genre. Is there a way to do that with listRooms?

bboe commented 11 years ago

@josephwegner listRooms fetches 20 at a time and is sorted by most popular rooms with the exception of first listing the current room (and maybe favorites). You can then perform your own filtering on the returned data.

technobly commented 11 years ago

You should be able to do an HTTP request through the bot for room.directory_rooms like I do with my Urban Dictionary lookup: https://github.com/alaingilbert/Turntable-API/wiki/Add-an-Urban-Dictionary-Look-up-Command

technobly commented 11 years ago

http://turntable.fm/api/room.directory_rooms

returns JSON formated data as follows:

[true,
{
    "rooms": [{
        "chatserver": ["chat4.turntable.fm", 80],
        "name": "Sounds of Liberty",
        "created": 1308869306.79,
        "shortcut": "sounds_of_liberty",
        "name_lower": "sounds of liberty",
        "roomid": "4e03c2ba14169c537a005ba5",
        "metadata": {
            "djs": [],
            "current_song": null,
            "privacy": "public",
            "max_djs": 5,
            "downvotes": 0,
            "random": 0.633199587881,
            "userid": "4e03befd4fe7d06138090a55",
            "featured": false,
            "listeners": 0.0,
            "djcount": 0,
            "current_dj": null,
            "moderator_id": ["4e03befd4fe7d06138090a55"],
            "upvotes": 0,
            "max_size": 200,
            "votelog": []
        }
    }, {
        "chatserver": ["chat5.turntable.fm", 80],
        "name": "Thursday Ho Hum Without The Techno",
        "created": 1308869319.89,
        "shortcut": "thursday_ho_hum_without_the_techno",
        "name_lower": "thursday ho hum without the techno",
        "roomid": "4e03c2c714169c537a005bba",
        "metadata": {
            "djs": [],
            "current_song": null,
            "privacy": "public",
            "max_djs": 5,
            "downvotes": 0,
            "random": 0.310731413982,
            "userid": "4e0343b1a3f751792204b9cc",
            "featured": false,
            "listeners": 0.0,
            "djcount": 0,
            "current_dj": null,
            "moderator_id": ["4e0343b1a3f751792204b9cc"],
            "upvotes": 0,
            "max_size": 200,
            "votelog": []
        }
    }, 
// ...
{
        "chatserver": ["chat4.turntable.fm", 80],
        "name": "Social Media",
        "created": 1308869865.0,
        "shortcut": "social_media",
        "name_lower": "social media",
        "roomid": "4e03c4e814169c54da00579f",
        "metadata": {
            "djs": [],
            "current_song": null,
            "privacy": "public",
            "max_djs": 5,
            "downvotes": 0,
            "random": 0.360816947185,
            "userid": "4dff84dca3f75104e00455f9",
            "featured": false,
            "listeners": 0.0,
            "djcount": 0,
            "current_dj": null,
            "moderator_id": ["4dff84dca3f75104e00455f9"],
            "upvotes": 0,
            "max_size": 200,
            "votelog": []
        }
    }]
}]
josephwegner commented 11 years ago

@DubbyTT Yeah, I can do the call manually, but it seems like a useful function to have it be part of the API. If it was an official API, I would certainly expect this to be a part of it.

@bboe Doing the request to directory_rooms gives us the ability to choose what our filters, limits, and sorts are. listRooms gives probably the most common combination of that, but I don't see any reason why people should be limited to those settings. Perhaps the solution is to override the current listRooms with this new version, but I really don't see why we would opt towards less options instead of more...

bboe commented 11 years ago

@josephwegner I see that it has added functionality. The only issue is that you are making an out-of-band request that isn't part of the turntable websocket API.

While this shouldn't cause problems in the node.js version of ttapi, it's not as easily integrated into the other versions of ttapi. That's not to say it isn't useful, but IMO it should appear differentiated from the websocket API.

josephwegner commented 11 years ago

Oh, I see. I didn't realize there were other versions of ttapi. Well, I'll leave it up to those with more investment to decide if it's worth the merge. I certainly understand if it's not.

alaingilbert commented 11 years ago

@bboe @josephwegner According to my experience, every api call are available over http and websocket. I'll check it out if it can be called with the websocket !

alaingilbert commented 11 years ago

hum, well this one does not seems to be callable via the websocket.