<commit_before>nTunes
======
### A REST (HTTP) API for interacting with iTunes

__nTunes__ (nodeTunes?) is an HTTP-based API for interacting with your
[iTunes][] installation (currently only for Mac OSX), written with [NodeJS][].

In other words, it's the foundation for writing web applications based on
your [iTunes][] library. You could potentially write a website that remotely
controls the volume of the [iTunes][] on your computer.

Usage
-----

__nTunes__ itself is a [Connect HTTP Server][connect] subclass, which can
either be run stand-alone or created by your own NodeJS code, with the
capability to add layers (to serve your implementing website perhaps?).


### Stand-alone mode...

To play around, you can run it stand-alone. Make sure you have
[`connect`](http://github.com/senchalabs/connect) and
[`spark`](http://github.com/senchalabs/spark) from
[__npm__](http://github.com/isaacs/npm), and are running [NodeJS][] on OS X,
then from the __nTunes__ root directory (where this README is) invoke:

    spark

This starts __nTunes__ as a stand-alone HTTP server in development mode. While
the server is running you can interact with your [iTunes][] library through
simple HTTP requests sent to your computer. Here are some examples:

  To get the name of the currently play track with a GET request:
  
    curl localhost:3000/currentTrack/name
      // Returns "Lateralus"

  To set your iTunes' volume to 50% with through a POST request:
  
    curl -d "value=50" localhost:3000/volume
      // Returns 50

The API mostly returns JSON encoded values, and is mostly intended to be used
with the `XMLHttpRequest` object and `JSON.parse` function in the web browser.


### Adding 'layers' to the `nTunes` module...

For familiarity, creating your own __nTunes__ instance works _exactly_ the
same as creating a [connect][] server, except that __nTunes__' layers get
added after your passed layers, so be _very_ careful not to overwrite part of
the __nTunes__ API! Here's an example of serving an `index.html` file when
it's requested, otherwise falling-through to the __nTunes__ layers:

    var nTunes = require("nTunes");

    nTunes.createServer(function(req, res, next) {
      if (req.url == "/index.html") {<commit_msg>Minor README tweaks to reflect the actual API.<commit_after>nTunes
======
### A REST (HTTP) API for interacting with iTunes

__nTunes__ (nodeTunes?) is an HTTP-based API for interacting with your
[iTunes][] installation (currently only for Mac OSX), written with [NodeJS][].

In other words, it's the foundation for writing web applications based on
your [iTunes][] library. You could potentially write a website that remotely
controls the volume of the [iTunes][] on your computer.

Usage
-----

__nTunes__ itself is a [Connect HTTP Server][connect] subclass, which can
either be run stand-alone or created by your own NodeJS code, with the
capability to add layers (to serve your implementing website perhaps?).


### Stand-alone mode...

To play around, you can run it stand-alone. Make sure you have
[`connect`](http://github.com/senchalabs/connect) and
[`spark`](http://github.com/senchalabs/spark) from
[__npm__](http://github.com/isaacs/npm), and are running [NodeJS][] on OS X,
then from the __nTunes__ root directory (where this README is) invoke:

    spark

This starts __nTunes__ as a stand-alone HTTP server in development mode. While
the server is running you can interact with your [iTunes][] library through
simple HTTP requests sent to your computer. Here are some examples:

  To get the `name` of the `current track` with a GET request:
  
    curl localhost:3000/current%20track/name
      // Returns "Lateralus"

  To set your iTunes' volume to 50% with through a POST request:
  
    curl -d value=50 localhost:3000/sound%20volume
      // Returns 50

The API mostly returns JSON encoded values, and is mostly intended to be used
with the `XMLHttpRequest` object and `JSON.parse` function in the web browser.


### Adding 'layers' to the `nTunes` module...

For familiarity, creating your own __nTunes__ instance works _exactly_ the
same as creating a [connect][] server, except that __nTunes__' layers get
added after your passed layers, so be _very_ careful not to overwrite part of
the __nTunes__ API! Here's an example of serving an `index.html` file when
it's requested, otherwise falling-through to the __nTunes__ layers:

    var nTunes = require("nTunes");

    nTunes.createServer(function(req, res, next) {
      if (req.url == "/index.html") {
{'fraction_non_alphanumeric': 0.08752492798581875, 'fraction_numerical': 0.0070906270773321515, 'mean_word_length': 4.236658932714617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5053343', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1262, 'n_words': 602}