This article describes the Python implementation of a set of commands that integrate the Songza jukebox website and the Enso command line system.
1. Introduction
This article describes a set of commands that integrate Humanized’s Enso, the linguistic command line interface, with Songza, the music search engine and internet jukebox.
songza list {song list} inserts the most played songs and the featured songs at Songza.com.
songza playlist inserts the playlist of the currently selected Songza.com username.
The Songza commands insert links to songs marked up in XHTML. For example, if you are working in Word and you want some music, simply insert a list of songs, such as your own playlist, click on a song link and the Songza website will open in your browser and start playing the song you clicked on. Clickable song lists are available in any application capable of rendering the list of XHTML links returned by the Songza commands.
The Songza commands for Enso are implemented in Python and contained in the SongzaEnsoExtension.py file. The Try It section below explains how to run the Songza commands for Enso with the Enso Developer Prototype.
2. The songza list {song list} Command
The songza list {song list} command inserts the most played songs and the featured songs at Songza.com.
songza list top inserts the most played songs.
songza list featured inserts the featured songs.
Both commands insert an unordered list of links to the songs at Songza.com marked up in XHTML. For example, the following XHTML markup from the songza command
would produce the following unordered list of links
in applications capable of rendering XHTML, such as Microsoft Word and OpenOffice Writer. In other applications, the raw XHTML is inserted.
The Songza.com Public Feed
The songza list {song list} command retrieves song lists in XML format from the public feed of the Songza API, which returns song lists in the following format:
Python Implementation
The classes that implement the Songza commands extend the AbstractSongzaCommand class. The AbstractSongzaCommand class extends the threading.Thread class to enable Songza commands to execute on a separate thread.
The __songzaList() function below implements the songza list {song list} command.
The SongzaListCommand class uses the buildXHTMLSongList() method of the AbstractSongzaCommand class to build the list of links marked up in XHTML.
3. The songza playlist Command
The songza playlist command inserts the playlist of the currently selected Songza.com username. The songs on the playlist are marked up in XHTML as an unordered list of links to the songs at Songza.com, as described above in the section on the songza list {song list} command.
The Songza.com Feed
The songza playlist command retrieves song lists in XML format from the feed of the Songza API, which returns song lists in the following format:
Python Implementation
The __songzaPlaylist() function below implements the songza playlist command.
The SongzaPlaylistCommand class uses the buildXHTMLSongList() method of the AbstractSongzaCommand class to build the list of links marked up in XHTML.