google-code-export / chirpradio

Automatically exported from code.google.com/p/chirpradio
0 stars 0 forks source link

Live site needs to accept playlist submissions #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When a DJ enters or deletes on-air playlist entries, those need to be
reflected in real time on the live site.

The live site runs in PHP and thus a simple PHP script needs to be written
that accepts a request that communicates the following:

For posting new entries:

- name of track played
- name of artist
- name of album
- name of label
- DJ who played the track
- time the track was played

It should return an ID number

For deleting entries:

- ID number to delete

Note that updates will be done by a delete followed by a post.

The easiest thing is to make this RESTful.  I.E. send a POST request to
add, send a DELETE request to delete.

Note that the push operation is covered by Issue 43

Original issue reported on code.google.com by kumar.mcmillan on 15 Dec 2009 at 10:55

GoogleCodeExporter commented 9 years ago
The live site is an installation of Textpattern, which you can get here
http://textpattern.com/download  Mike has some instructions for how the playlist
entries will need to be created in the MySQL db.

Original comment by kumar.mcmillan on 15 Dec 2009 at 10:59

GoogleCodeExporter commented 9 years ago
I'm wondering why we can't insert some javascript in Textpattern to pull the 
current
song from the PlaylistTracker.  Doing this with javascript would have the added
benefit of allowing the song to be updated without reloading the page.

Then, all we would have to do is set up a proxy on the webserver to pass the
javascript call of the API on to the PlaylistTracker.  Doing it this way seems 
like
it would take out the need for authentication since we don't need to restrict 
people
being able to access the current song via an exposed PlaylistTracker api.  

What do you all think?

Original comment by geoffh...@gmail.com on 17 Dec 2009 at 8:14

GoogleCodeExporter commented 9 years ago
Geoff, this was a discussion we had a long time ago. The answer is that I need 
these
entered as articles into the database because I'm doing a lot more than just 
powering
the "currently playing" call on the web page. I'm generating weekly top 
artists, I'm
generating url structures we can use to pull up days worth of playlists for 
Royalty
tracking. There's a bunch going on and for it to work, it needs to be added to 
the
database. 

That's not something that is going to change. What is up for debate by 
programmers
much smarter than myself is whether this is done via pinging a php script, or a 
cron
job that runs on the server or any other method, as long as it gets into the db.

Thanks.

Original comment by lovehasn...@gmail.com on 17 Dec 2009 at 8:18

GoogleCodeExporter commented 9 years ago
I'll send the db connection info to whoever needs it once they start working on 
this,
but here are the fields in the db that need to be populated for each entry...

------------------

In that database, there's a table called "textpattern" and that's where all the
articles should go. Here are the rows in it.

ID (ID# of the post, counting up from 1. EVERY article in TXP gets an ID from 
the
same pool, not just the playlist items)

Posted (date/time posted, 24 hour clock formatted like 2008-09-02 06:31:18)

Expires (Can we set this to exactly one week later than the play time?)

AuthorID (username of the author. Now, just set this as me, username 
lovehasnologic.
It's for the easiest. You can then ignore all the info below about creating 
users.)

LastMod (for the playlist, this'll be the same as the post time)

LastModID (blank)

Title (Song Title)

Title_html (Blank)

Body (Album Title (If blank, we need to figure out a generic term as Sound 
Exchange
makes this mandatory. Unreleased maybe, but this'll also display on the site, 
so we
need to figure this out so it works for both.)

Body_html (Album Title with <p> tags around it)

Excerpt (Additional Notes (Such as "Playing at Schuba's on Saturday")

Excerpt_html (Same as excerpt with <p> tags around it)

Image (blank)

Category1 (blank)

Category2 (blank)

Annotate (Set as "1")

AnnotateInvite (Set as "Comment")

comments_count (blank)

Status (Set as "4")

textile_body (set as "1")

textile_excerpt (set as "1")

Section (playlists)

override_form (blank)

Keywords (Artist Name)

url_title (Can we set as "id-artist-name-song-title" limiting the entire thing 
to no
more than 200 characters?"

custom_1 (record label)

custom_2 (This'll be the name of the On Air DJ. I'm sure you can pass the name 
to
this field as plain text, yes? That way the username in the Playlist App can 
reflect
whatever they want to show, whether they use a specialty show name down the 
road, DJ
Bylamplight or just their normal name.)

custom_3 (rest of these are blank for the time being)
custom_4
custom_5
custom_6
custom_7
custom_8
custom_9
custom_10

uid (This appears to be an MD5 hash. I have no idea how it is generated. 
Perhaps you
need to dig through the TXP code. Here's one example: 
dce16e0ddd7f650567ce96a305682881)

feed_time (This just appears to be the time the item appears in the RSS Feed? 
Not
sure, but it's always the same as the posted date, but just the yyyy-mm-dd)

Original comment by lovehasn...@gmail.com on 17 Dec 2009 at 8:26

GoogleCodeExporter commented 9 years ago
yeah, the easiest thing would be to display the currently playing tracks with a
javascript widget.  This would also allow the dev team to bang out some cool 
features
like letting users favorite tracks and such.

I wonder if makes sense to revisit the idea of providing feeds for everything 
the
live site needs?  i.e. we could easily provide feeds of weekly top artists and 
all
the playlists for royalty tracking.  

The database on App Engine will support all of that quite easily and all the 
devs
helping out will be able to add features to that site easier than the 
Textpattern PHP
site, I'd think.

Original comment by kumar.mcmillan on 17 Dec 2009 at 8:30

GoogleCodeExporter commented 9 years ago
can we please not rehash this? all of the work I've done up until now has been 
done
on the premise that we would be inserting these items as articles into the 
database.
It's how I've built the site and is what was agreed upon months ago. I'd really 
like
to just know that these are going to be inserted into the db so I can continue 
doing
what I need to do for completion and not worrying about having to rewrite a 
bunch of
different pieces of it.

Original comment by lovehasn...@gmail.com on 17 Dec 2009 at 8:37

GoogleCodeExporter commented 9 years ago
Sorry, I didn't realize all the templates on the live site had already been 
built,
cool!  OK, then the simplest thing right now is to continue building this 
secure PHP
script (as described in the ticket) that accepts playlist admonitions in 
realtime as
the user is entering them while on the air in the studio.

Original comment by kumar.mcmillan on 17 Dec 2009 at 8:56

GoogleCodeExporter commented 9 years ago
@lovehasnologic Makes sense.  

It seems that we're leaning to just doing strait SQL inserts into the 
Textpattern
database (rather than writing a textpattern plugin or custom code using the TP 
API)
to add "articles" to the live site.

Is it possible to run Django on the live site webserver with mod_python?  It's
certainly possible to implement the custom REST API for inserting the articles 
into
the DB in PHP, but it seems a smoother, probably quicker implementation and more
consistent with the other architecture to just do it in Django.  Thoughts?

Original comment by geoffh...@gmail.com on 18 Dec 2009 at 9:33

GoogleCodeExporter commented 9 years ago
unfortunately, no.  Our mediatemple account is pretty much limited to PHP at the
moment.  They offer a "Django shell" but it costs extra and not something our 
account
supports.

Original comment by kumar.mcmillan on 18 Dec 2009 at 9:48

GoogleCodeExporter commented 9 years ago
Here's the db export....

-- phpMyAdmin SQL Dump
-- version 2.11.0
-- http://www.phpmyadmin.net
--
-- Host: internal-db.s49693.gridserver.com
-- Generation Time: Dec 20, 2009 at 10:04 AM
-- Server version: 5.0.51
-- PHP Version: 4.4.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `db49693_chirpradio_txp`
--

-- --------------------------------------------------------

--
-- Table structure for table `textpattern`
--

CREATE TABLE `textpattern` (
  `ID` int(11) NOT NULL auto_increment,
  `Posted` datetime NOT NULL default '0000-00-00 00:00:00',
  `Expires` datetime NOT NULL default '0000-00-00 00:00:00',
  `AuthorID` varchar(64) NOT NULL default '',
  `LastMod` datetime NOT NULL default '0000-00-00 00:00:00',
  `LastModID` varchar(64) NOT NULL default '',
  `Title` varchar(255) NOT NULL default '',
  `Title_html` varchar(255) NOT NULL default '',
  `Body` mediumtext NOT NULL,
  `Body_html` mediumtext NOT NULL,
  `Excerpt` text NOT NULL,
  `Excerpt_html` mediumtext NOT NULL,
  `Image` varchar(255) NOT NULL default '',
  `Category1` varchar(128) NOT NULL default '',
  `Category2` varchar(128) NOT NULL default '',
  `Annotate` int(2) NOT NULL default '0',
  `AnnotateInvite` varchar(255) NOT NULL default '',
  `comments_count` int(8) NOT NULL default '0',
  `Status` int(2) NOT NULL default '4',
  `textile_body` int(2) NOT NULL default '1',
  `textile_excerpt` int(2) NOT NULL default '1',
  `Section` varchar(64) NOT NULL default '',
  `override_form` varchar(255) NOT NULL default '',
  `Keywords` varchar(255) NOT NULL default '',
  `url_title` varchar(255) NOT NULL default '',
  `custom_1` varchar(255) NOT NULL default '',
  `custom_2` varchar(255) NOT NULL default '',
  `custom_3` varchar(255) NOT NULL default '',
  `custom_4` varchar(255) NOT NULL default '',
  `custom_5` varchar(255) NOT NULL default '',
  `custom_6` varchar(255) NOT NULL default '',
  `custom_7` varchar(255) NOT NULL default '',
  `custom_8` varchar(255) NOT NULL default '',
  `custom_9` varchar(255) NOT NULL default '',
  `custom_10` varchar(255) NOT NULL default '',
  `uid` varchar(32) NOT NULL default '',
  `feed_time` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`ID`),
  KEY `categories_idx` (`Category1`(10),`Category2`(10)),
  KEY `Posted` (`Posted`),
  KEY `section_status_idx` (`Section`,`Status`),
  KEY `Expires_idx` (`Expires`),
  KEY `author_idx` (`AuthorID`),
  FULLTEXT KEY `searching` (`Title`,`Body`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 PACK_KEYS=1 AUTO_INCREMENT=8 ;

--
-- Dumping data for table `textpattern`
--

INSERT INTO `textpattern` (`ID`, `Posted`, `Expires`, `AuthorID`, `LastMod`,
`LastModID`, `Title`, `Title_html`, `Body`, `Body_html`, `Excerpt`, 
`Excerpt_html`,
`Image`, `Category1`, `Category2`, `Annotate`, `AnnotateInvite`, 
`comments_count`,
`Status`, `textile_body`, `textile_excerpt`, `Section`, `override_form`, 
`Keywords`,
`url_title`, `custom_1`, `custom_2`, `custom_3`, `custom_4`, `custom_5`, 
`custom_6`,
`custom_7`, `custom_8`, `custom_9`, `custom_10`, `uid`, `feed_time`) VALUES
(1, '2008-09-02 06:31:18', '0000-00-00 00:00:00', 'lovehasnologic', '2008-09-02
06:31:18', '', 'First Post', '', 'Lorem ipsum dolor sit amet, consectetuer 
adipiscing
elit. Donec rutrum est eu mauris. In volutpat blandit felis. Suspendisse eget 
pede.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos
hymenaeos. Quisque sed arcu. Aenean purus nulla, condimentum ac, pretium at, 
commodo
sit amet, turpis. Aenean lacus. Ut in justo. Ut viverra dui vel ante. Duis 
imperdiet
porttitor mi. Maecenas at lectus eu justo porta tempus. Cras fermentum ligula 
non
purus. Duis id orci non magna rutrum bibendum. Mauris tincidunt, massa in 
rhoncus
consectetuer, lectus dui ornare enim, ut egestas ipsum purus id urna. Vestibulum
volutpat porttitor metus. Donec congue vehicula ante.', '   <p>Lorem ipsum dolor 
sit
amet, consectetuer adipiscing elit. Donec rutrum est eu mauris. In volutpat 
blandit
felis. Suspendisse eget pede. Class aptent taciti sociosqu ad litora torquent 
per
conubia nostra, per inceptos hymenaeos. Quisque sed arcu. Aenean purus nulla,
condimentum ac, pretium at, commodo sit amet, turpis. Aenean lacus. Ut in 
justo. Ut
viverra dui vel ante. Duis imperdiet porttitor mi. Maecenas at lectus eu justo 
porta
tempus. Cras fermentum ligula non purus. Duis id orci non magna rutrum bibendum.
Mauris tincidunt, massa in rhoncus consectetuer, lectus dui ornare enim, ut 
egestas
ipsum purus id urna. Vestibulum volutpat porttitor metus. Donec congue vehicula
ante.</p>\n\n\n ', '', '', '', 'hope-for-the-future', 'meaningful-labor', 1,
'Comment', 1, 4, 1, 1, 'playlists', '', '', 'first-post', '', '', '', '', '', 
'', '',
'', '', '', 'dce16e0ddd7f650567ce96a305682881', '2008-09-02'),
(2, '2009-12-17 17:46:32', '0000-00-00 00:00:00', 'lovehasnologic', '2009-12-17
12:58:23', 'lovehasnologic', 'The Boat Dreams From The Hill', '', '24 Hour 
Revenge
Therapy', ' <p>24 Hour Revenge Therapy</p>', 'Never playing again', '   <p>Never
playing again</p>', '', '', '', 0, 'Comment', 0, 4, 1, 1, 'playlists', '',
'Jawbreaker', '2-jawbreaker-the-boat-dreams-from-the-hill', 'Tupelo', 'Dustin 
Drase',
'', '', '', '', '', '', '', '', 'e84ff2c7abe5102372904ec19074c4a2', 
'2009-12-17'),
(3, '2009-12-17 12:48:42', '0000-00-00 00:00:00', 'lovehasnologic', '2009-12-17
12:58:07', 'lovehasnologic', 'Day Dangerous', '', 'Exiting Arm', '  <p>Exiting
Arm</p>', '', '', '', '', '', 0, 'Comment', 0, 4, 1, 1, 'playlists', '', 
'Subtle',
'3-subtle-day-dangerous', 'Lex Records', 'Dustin Drase', '', '', '', '', '', 
'', '',
'', 'f1e284b6bee298d624a74136453583dc', '2009-12-17'),
(4, '2009-12-17 12:53:07', '0000-00-00 00:00:00', 'lovehasnologic', '2009-12-17
12:57:54', 'lovehasnologic', 'Hey, Is That A Ninja Up There', '', 'They Make 
Beer
Commercials Like This ', '  <p>They Make Beer Commercials Like This </p>', '', 
'', '',
'', '', 0, 'Comment', 0, 4, 1, 1, 'playlists', '', 'Minus The Bear',
'4-minus-the-bear-hey-is-that-a-ninja-up-there', 'Suicide Squeeze', 'Dustin 
Drase',
'', '', '', '', '', '', '', '', 'b12a9a78bb6e8c08488f58737bc94bc7', 
'2009-12-17'),
(5, '2009-12-17 12:54:14', '0000-00-00 00:00:00', 'lovehasnologic', '2009-12-17
12:57:35', 'lovehasnologic', 'A Finger To Hackle', '', 'Scratch or Stitch', '
<p>Scratch or Stitch</p>', '', '', '', '', '', 0, 'Comment', 0, 4, 1, 1, 
'playlists',
'', 'Melt-Banana', '5-melt-banana-a-finger-to-hackle', 'GSL', 'Dustin Drase', 
'', '',
'', '', '', '', '', '', 'd70c5297287051f55f33cbe1790315c0', '2009-12-17'),
(6, '2009-12-17 12:54:54', '0000-00-00 00:00:00', 'lovehasnologic', '2009-12-17
12:57:18', 'lovehasnologic', 'Yellow, Blue and Green', '', 'Quetzalcoatl', '
<p>Quetzalcoatl</p>', 'R.I.P. Lance Hahn', '    <p>R.I.P. Lance Hahn</p>', '', '', 
'',
0, 'Comment', 0, 4, 1, 1, 'playlists', '', 'J Church',
'6-j-church-yellow-blue-and-green', 'Allied', 'Dustin Drase', '', '', '', '', 
'', '',
'', '', '60d268936e224816d878292f6a5a882f', '2009-12-17'),
(7, '2009-12-17 12:55:38', '0000-00-00 00:00:00', 'lovehasnologic', '2009-12-17
12:57:01', 'lovehasnologic', 'Escape From New Rock', '', 'A+ Electric', '   <p>A+
Electric</p>', '', '', '', '', '', 0, 'Comment', 0, 4, 1, 1, 'playlists', '',
'Crushstory', '7-crushstory-escape-from-new-rock', 'Pop Kid Records', 'Dustin 
Drase',
'', '', '', '', '', '', '', '', '70f98e1397419e954e8c03ee879e21b5', 
'2009-12-17');

Original comment by lovehasn...@gmail.com on 20 Dec 2009 at 6:05

GoogleCodeExporter commented 9 years ago
Re comment #4 (http://code.google.com/p/chirpradio/issues/detail?id=44#c4):

comment_3 field in database will hold the ID from the the playlist app.

Original comment by geoffh...@gmail.com on 20 Dec 2009 at 9:01

GoogleCodeExporter commented 9 years ago

Original comment by kumar.mcmillan on 20 Dec 2009 at 9:18

GoogleCodeExporter commented 9 years ago
Re: comment 11 (http://code.google.com/p/chirpradio/issues/detail?id=44#c11)

This comment should have read 

The custom_3 field in the database will hold the track ID from the playlist app.

This is important because it will allow the playlist app to delete entries 
pushed to
Textpattern without having to keep track of the Textpattern article IDs.

Original comment by geoffh...@gmail.com on 21 Dec 2009 at 8:56

GoogleCodeExporter commented 9 years ago
I have a working prototype of this running at 
http://geoff.terrorware.com/hacks/chirpapi/

See
http://code.google.com/r/geoffhing-chirpradio/source/browse/chirpradio_live_site
/README.txt
for the API documentation and examples of using curl to test the API.

Still TODO:

* Clean up the semantics a little.  
** Should the API method be playlist/create or playlist/update?  Currently its
create, but update seems better to me.
* There's a disconnect between the initial spec in this issue and the way we 
have to
handle things because of Textpattern.  I'm thinking that delete should only 
take the
playlist apps id as an argument (currently there are two versions of the delete
method, playlist/delete/website and playlist/delete/playlist-app which take 
different
IDs).  I can't imagine the case where we would delete based on the website
(Textpattern internal) ID.  The create method should return both the 
textpattern id
(even though it won't be used, and the playlist app id).
* Implement an authentication scheme
* Break class definition out into its own php file
* Document the code and move API documentation inline

Original comment by geoffh...@gmail.com on 21 Dec 2009 at 9:02

GoogleCodeExporter commented 9 years ago
From your spec, the PHP script accepts POST parameter playlist_track_id which 
is the
App Engine Datastore entity key of the track and will look something like
agpjaGlycHJhZGlvcg8LEghQbGF5bGlzdBiIBQw 

I think the delete method should only delete entries based on this ID parameter.

Original comment by kumar.mcmillan on 21 Dec 2009 at 10:48

GoogleCodeExporter commented 9 years ago
FYI, I'm now using custom_4 for scheduling purposes, so if another field needs 
to be
added, you should jump to custom_5. Just let me know so we can keep each other 
in
line with one another.

Original comment by lovehasn...@gmail.com on 22 Dec 2009 at 4:52

GoogleCodeExporter commented 9 years ago
I updated the API semantics to reflect deletion by key/id from the playlist app 
and to 
make the method parameters and return value names more consistent.  See 
http://code.google.com/r/geoffhing-
chirpradio/source/browse/chirpradio_live_site/README.txt for the updated API 
documentation.

I'm in the process of implementing Digest HTTP Authentication for some of the 
API 
methods, so client code might be broken for a little while.

Original comment by geoffh...@gmail.com on 25 Dec 2009 at 8:07

GoogleCodeExporter commented 9 years ago
The playlist/create and playlist/delete methods are now require authentication 
using 
HTTP digest authentication (see 
http://en.wikipedia.org/wiki/Digest_access_authentication)

Original comment by geoffh...@gmail.com on 26 Dec 2009 at 12:52

GoogleCodeExporter commented 9 years ago
Excellent, I think digest auth is good enough to get us started.

Original comment by kumar.mcmillan on 27 Dec 2009 at 1:39

GoogleCodeExporter commented 9 years ago
Hey Geoff, when working with the code I noticed that the REST api does not 
accept
track_notes but it should.  It looks like there is a place for this in the 
article
table as the Excerpt column.

Original comment by kumar.mcmillan on 31 Dec 2009 at 5:35

GoogleCodeExporter commented 9 years ago
Quick update: working on this with a local TP installation.  Running into 
problems
making my RewriteRules for the API play with the TP ones.  Should be able to 
figure
it out but I need to read the mod_rewrite docs.

Original comment by geoffh...@gmail.com on 6 Jan 2010 at 4:45

GoogleCodeExporter commented 9 years ago
Update: Worked our rewrite rule stuff.  Added support for track_notes for
playlist/current and playlist/create.  

Still TODO: Change to new URL scheme, use tp config file.

I'm getting closer.  Sorry Mike.  Won't be done with this until tonight.

Original comment by geoffh...@gmail.com on 6 Jan 2010 at 6:56

GoogleCodeExporter commented 9 years ago
Updated the URL-only title and textpattern config updates into my local version 
and
did some quick testing.  Need to push this to the repo.

Original comment by geoffh...@gmail.com on 6 Jan 2010 at 9:16

GoogleCodeExporter commented 9 years ago
Pushed my updates to my repo.

Original comment by geoffh...@gmail.com on 6 Jan 2010 at 9:27

GoogleCodeExporter commented 9 years ago
Thanks Geoff!  Your changes look good and I've pushed them to the main repos 
(you
should pull from main when you get a chance).  Here's what we do next.  Mike can
follow your instructions (or chat with you) about installing the code and 
editing the
textpattern settings on the chirpradio.org.  Then you guys can test it with some
fabricated POSTs.  Once it's working, let me know and I'll change the URL in 
the live
configuration which will make it send real POSTs as DJs enter in their playlist 
info.  

Note that there is one bug in the chirpradio.appspot.com code that causes
intermittent failures when POSTing playlist changes.  I hope to have that fixed 
soon,
hopefully by tonight.

Mike, I sent you instructions in a separate email for installing Mercurial (the 
hg
command).  Once you have that working, you can get Geoff's PHP code by 
following the
hg clone instructions here: http://code.google.com/p/chirpradio/source/checkout

Original comment by kumar.mcmillan on 6 Jan 2010 at 10:22

GoogleCodeExporter commented 9 years ago
Closing this since it's deployed and the remaining bugs are tracked in other 
issue #s.

Original comment by geoffh...@gmail.com on 8 Jan 2010 at 4:59