nickdesaulniers / audiostream

Stream and transcode your music library over HTTP
42 stars 8 forks source link

Add new directories to the config.json file #22

Open sr-ix opened 11 years ago

sr-ix commented 11 years ago

It would be nice to be able to add new directories to the list of paths to search for media from the web.

In fact it would be nice to have some kind of interface to the config options in general.

nickdesaulniers commented 11 years ago

I really like the idea of fetching media from the web. Find one that's hosted elsewhere using something like this and be able to stream it from them, transcoding if needed. ;)

nickdesaulniers commented 11 years ago

And yes, the web interface should allow users to modify their directories, without having to modify a config file and restart the server.

sr-ix commented 11 years ago

I've been experimenting and found this nice module, nconf, which is used in nodejitsu's flatiron framework.

I'm going to build a config.ejs page that will use this as a demo.

sr-ix commented 11 years ago

I've written a small, extensible script (lib/config.js) which creates an object with methods to add & remove tracks from the config.json using nconf & underscore.js. These two packages were used for simplicity and proof of concept and the same could be done without them.

I think rather than a separate config.ejs view, the configuration of user options could be done in a settings widget/modal that uses the methods from the config.js object on any page of the application.

sr-ix commented 11 years ago

One sub-issue with this method is that it doesn't mesh well with the way the application builds it's file list using the filemap.

Adding a new path to the music_folders config.json option updates the file on the disk, but this change is not recognized until the app is restarted.

nickdesaulniers commented 11 years ago

Just add a method to the filemap to manipulate the underlying hash, file_dict. Everything is stored in memory at the moment, but we'll probably have a db backend as well at some point.

nickdesaulniers commented 11 years ago

@sr-ix , when the user modifies their config, send an ajax request, add a new route for updating the config, write the changes to file, and just call FileMap.update() to rescan the dirs from the config file. Then redraw the table listing.

nickdesaulniers commented 11 years ago

I think it would be helpful to use command line arguments or some other means to specify whether or not to use redis or default to a file. That way, a lone user doesn't need to install a db backend dependency, but we can and enable the app to run using redis with just a non default command line arg. eg:

Single user:

$ audiostream start

Us:

$ audiostream start -redis connection@string