Make a Live Request via Twitter - and have it played automatically on Mix FM

Started by mixfm, January 27, 2010, 04:38:23 AM

Previous topic - Next topic

mixfm

I've implemented a few scripts that interact with the OtsAV RAC to enable people to request a song via Twitter (see http://www.co.nz/mixfm/request.php) and the request is automatically injected into the playlist.

In fact, it even injects a short dry voice-over which says "Wellington's best music, Mix FM.  And now, a live request via Twitter." before the song.

Give it a go on Twitter!  Simply tweet "@mixfm_request" followed by song title and artist name.

I do believe this is a first for an FM broadcast station (I know AOL Radio are doing it but they are online streaming only, and a handful of FM broadcast stations accept requests via Twitter but it's not automated  - it's just like sending them an email saying "can you play xyz").

But.... if you know of another FM broadcast station doing fully automated requests via Twitter - let me know and I'll withdraw my claim at being first :-)

Jumpin' Jeff

Cool Mix!
I gotta ask though...
Is the request placed at the end of the playlist, or the top?
Jeff Main

You can please some of the people some of the time, all of the people some of the time, some of the people all of the time, but you can never please all of the people all of the time. 
Abraham Lincoln
 
OtsAV license holder for life.
PDI: OtsAV TV Broadcaster PARC-KHY7

mixfm

Quote from: Artist formerly known as 'Jumpin' Jeff' on January 27, 2010, 12:44:25 PM
Cool Mix!
I gotta ask though...
Is the request placed at the end of the playlist, or the top?

I've implemented so that it injects the song at the top.  So if you request a song now, it will play next.  But I have some smarts in it, so say you request a song now, and 30 seconds later Fred request another song, your song is injected straight away, and Fred's remains in a "holding pen" until your song plays.  When your song plays, Fred's comes out of the holding pen and is injected.

The reason for this is that if I just inject songs as they are requested, they would play in reverse order when there are lots of requests at once.

Quote from: DJ-Zath on January 28, 2010, 09:56:54 AM
you're  not the first!

I've been doing something simular on WARP Radio for a little over a year now..  

Damn.... so yours is fully automated too then?  And via Twitter?  Tell me about your so I can try it out!

Quote from: DJ-Zath on January 28, 2010, 09:56:54 AM
at the time of this writing, I haven't downloaded your app (yet)

Oh, it's not my "Now Playing Tool" that does this - I've written something quite different and haven't offered it for download.

Quote from: DJ-Zath on January 28, 2010, 09:56:54 AM
but I can tell you, first-hand, in that I have, myself, written an app that interfaces the RAC directly..
you will want to AVOID any direct access to the RAC.. ESPECIALLY if its running mission critical for if more than a handful of peeps attempt to call in requests and searches, it WILL crash ots!
The RAC wasn't designed for high-volume requests and it can NOT handle them!
furthermore, you will want to implement some sort of "abuse filters" or you're going to get someone who will request the same song many MANY times in a row!
just some friendly advice!

Thanks for the advice.  In fact the way I've implemented it, the whole catalogue is sucked out of Ots whenever I want (probably only once a fortnight because I don't add many new tracks these days).  

The application only queries and searches against the database copy (stored in mySQL), so it doesn't go via the RAC.

The only time it checks the RAC is if someone's requested a song, to check whether it's okay to inject (i.e. is there a previous request, and if so, has it finished playing yet?).

I have also implemented a maximum queue of 4 tracks.  So once the request queue reaches 4, it says "no more requests".

I have not yet implemented restrictions based around maximum number of requests per Twitter account in any given time period, but I can easily add that on if I need to.


Jumpin' Jeff

Jeff Main

You can please some of the people some of the time, all of the people some of the time, some of the people all of the time, but you can never please all of the people all of the time. 
Abraham Lincoln
 
OtsAV license holder for life.
PDI: OtsAV TV Broadcaster PARC-KHY7

Lane

How did you choose to suck the data out? I was debating methods myself. Basically I'm wondering if you get it through the RAC or the OML.
It's all just programming :P

mixfm

Quote from: Lane on January 28, 2010, 04:56:52 PM
How did you choose to suck the data out? I was debating methods myself. Basically I'm wondering if you get it through the RAC or the OML.

The RAC.  You can effectively search for "everything" - try this URL out yourself:

http://YOUR_IP_ADDRESS/x/search.cgi?searchby=any&matchtype=contain&searchtext=&first=0

My script steps through each page until the end,gathering the IDs of each song.  It then loads up each song page in turn (http://YOUR_IP_ADDRESS/x/item.cgi?ID_NUMBER), from which it gathers the artist name, song title and duration.  (I need the duration to estimate how soon a request will be played which is tweeted back to the requestor - e.g. "Thanks for your request.  Grace Kelly by Mika will be played in approximately 9 minutes").

Only I can trigger this entire database refresh.


Something I was wondering was how to interpret the Ots OML file format - has someone managed to reverse-engineer this?  In other words, has someone figured out the format of it so extract song information?  Only thing is I suspect duration isn't stored in the OML file, right?

Lane

I believe Ots has offered people info on how to read the oml through an sdk or something, with the requirement you sign an nda. Don't quote me on that. People have been known to reverse engineer these things obviously. There has been posts on that in the past.

The main issue I recall with reading data from the oml when I was looking at this was the fact I couldn't find the ID number in there. Maybe it was there, and I couldn't find it.  Without knowing the ID number, selecting the track in the rac can't be properly done. You're pretty much forced to come back to reading that date out of the rac.

My own script scraped the data by reading info on each possible number, one at a time. It went pretty quick actually.  Anyway, I long abandoned that project.
It's all just programming :P

milky

If you select all items in the ML, right click and export as text, you get a structured file with Artist, track and duration in it, like this.
Aaron Bolton - Rockin' Up (3:47)
Aaron Lines - Waitin' On Wonderful (3:51)
ABBA - Bang-A-Boomerang (2:59)
ABBA - Chiquitita (5:16)


I use it for display program which counts down the last 30 seconds of each track. Of course, each time you add or change yur tracks, you must refresh the text file, and I sort it in artist sequence before exporting.
OtsDJ           PDI = PAAA-BHVP,  PBQN-3658
S & L               PDI = PAAA-BK27 x 2
Studio             PDI = PAAA-BL38

mixfm

DJ-Zath - wow, what you have done sounds impressive.  I particularly like how you've thought about limiting the system to 1 search at a time so as not to overload Ots, and the only-one-song-per-10 limit.

And, it is kinda neat to have everything together in the one script and not relying on a database here, a server there, some other script elsewhere.  Tidy, self-contained code is nice!  Good work, fellow programmer!

By the way, when I checked (i.e. just a couple of minutes ago) you were off air, so your icon showed "Off air" and the playlist said "No data available", but I can imagine how you'd have been able to display the tracks.


Milky - yeah, as DJ-Zath just said, I'm wanting to suck out the library by initiating a command remotely (i.e. from a server), and have it fully automated.  In other words, press a button and my mySQL database (on a remote server) is automatically populated.  Ideally I could schedule this to run say, once a week, or once a fortnight automatically.  Even if I could automate your suggestion, the problem about the format is that you can't necessarily parse the data.  For example, consider:
Blue Monkeys - Caged - Nowhere To Run
So what's the name of the artist, and what's the title of the song?
Is it Blue Monkeys singing Caged - Nowhere To Run or is it Blue Monkeys - Caged singing Nowhere To Run?
That's why when my script performs the "search for everything" query, it doesn't just attempt to parse in the artist and title.  Instead it then loads the individual URL for each track in turn where the artist and title are clearly separated by HTML tags.  (And I also get the duration which I don't have in the search results).

Tim Gainer

...and here I was proud of myself just for making a website for my station! This stuff's Quantum Theory compared to me these days!  :wowza:

Yeah - all of this is way impressive...I'm anxious to see how you guys are gonna top this.
Ots Radio Broadcaster 1.94
PDI=PB5E-FGPP
Ots DJPro 1.94
PDI=PBN6-ZLTL
Ots DJPro 1.90
PDI=PBXH-PNK9


If music is the food of the soul, then play on...

:aGuitar:

Darryl

Quote from: milky on January 28, 2010, 10:52:45 PM
If you select all items in the ML, right click and export as text, you get a structured file with Artist, track and duration in it, like this.
Aaron Bolton - Rockin' Up (3:47)
Aaron Lines - Waitin' On Wonderful (3:51)
ABBA - Bang-A-Boomerang (2:59)
ABBA - Chiquitita (5:16)


I use it for display program which counts down the last 30 seconds of each track. Of course, each time you add or change yur tracks, you must refresh the text file, and I sort it in artist sequence before exporting.

I used exactly this technique for getting the info out of the Media Library for the Karaoke Hoster.  Unfortunately it doesn't solve the issue of the item number for the RAC query.

Have fun,
Darryl.
OtsAV: PDI PAAA-BFDR

Version 3.0.8.0 of the Karaoke Hoster is available now - http://sourceforge.net/projects/karaokehoster

Checkout my CDG Editor - repair badly ripped CDG Karaoke files with ease: http://sourceforge.net/projects/cdgeditor/

Now Playing in OtsAV - https://sourceforge.net/projects/nowplayinginots/ - Show your Windows Live Messenger contacts what you are listening to in OtsAV.

mixfm

I've completely revamped this.

The original solution was PHP-based and queried a database which was an export of the OtsAV media library.

This new solution is software that can run locally, either on the OtsAV machine or another machine.  The only requirement is that the machine on which it runs has an Internet connection (to be able to monitor Twitter mentions and send replies) and is able to connect to the OtsAV RAC.  The purpose of the RAC is to perform the search and (hopefully) identify the song the person is asking for.  The RAC is also the mechanism used to queue the next song.

It's still a (new) work in progress but hopefully I can share the software when it's a little more ready (keep an eye on this thread if you're keen to get your hands on the software!). A feature I plan to add soon is an optional post-roll (currently there's an optional pre-roll feature that inserts a specific track prior to the request).

Attached is a short audio snippet of a request being played through Ots.  You hear the outgoing track, the pre-roll, and then the incoming requested track.

mixfm