# http-music(1) http-music, June 2017 [adapted from old-guide.1 on 2021-07-19 using mle86/man-to-md: https://github.com/mle86/man-to-md] # Guide The most basic usage of **http-music** is simply that: http-music This loads the playlist.json file, selects a random track entry, downloads its URL, and plays the downloaded file. But before you can actually play anything, you'll need to have a playlist.json file. A playlist file is, essentially, a list of tracks. A track exists simply as a two-item array: a title and a download URL. So, this could work as an example playlist.json file: [ ["Yes", "http://billwurtz.com/yes.mp3"], ["Foobar", "http://example.com/foobar.wav"] ] Then when we run **http-music**, one of these two tracks will be selected (randomly), downloaded, and played. But it'd be annoying to have to fill in all of those URLs and tracks yourself. Chances are, you already have a media library your main computer. It's pretty easy to make http-music download music from that computer. http-music streams music from HTTP servers (obviously); so you'll need to get an HTTP server running on the computer with your music. Chances are that's actually really easy, though - Python has a convenient built-in HTTP server. Getting it to work is as easy as cd'ing into your media folder and running **python3 -m http.server** or **python2 -m SimpleHTTPServer**. Once you've got that running, you can let http-music do all the hard work. Just type in this command, substituting server_ip:port with the server and port for your Python HTTP server (you should be able to copy this into your browser and get a directory listing): http-music-crawl-recursive (server_ip:port) > playlist.json Now if you run **http-music** (in the same directory), the music in your media folder should start playing. If you'd like to have two playlists (perhaps you have two computers with separate media libraries), you can select the library you want http-music to play from by using the **--open (playlist file)** option. Now that you've got a proper large playlist (or two) gotten straight from a server on your computer, you're ready to, you know, listen to music. But sometimes it might be that you want to listen to a specific author, rather than EVERYONE. **http-music-crawl-recursive** actually sorts your music exactly the way they're stored in your media folder. That means that if you're using any sensible method of keeping that folder organized, it won't take much to listen to a specific sub-folder. Before we do anything, let's make clear a bit of terminology - http-music-crawl-recursive takes the folders in the listing URL you give it and sorts them into "groups". By using groups, you can make a tree of some sort; in your playlist.json file, that might look something like this: [ ["Song", "http://example.com/song.mp3"], ["Foo", [ ["Foo - Baz!!", "http://example.com/foo/foo-baz.mp3"], ["Foo - Rainbows", "http://example.com/foo/rainbows.mp3"] ]] ] As you can see, there's one group in that playlist file - "Foo". Now, suppose you ONLY want to play songs in the Foo group? Using two options, you can do that. Here's the command you'd use: http-music --clear --keep "Foo" That **clear**s out the entire playlist and **keep**s the "Foo" group. And don't worry - it only clears out the "active" playlist; this won't modify your real playlist.json file (http-music will never do that). At this point, it might also be worth mentioning the **--list-all** option. **--list-all** (alias: **-L**) prints out a visual representation of all of the groups and tracks in your album. Let's say we still have that playlist.json file (the one with the "Foo" group) and see some examples of it: $ http-music --list-all Song Foo/ | Foo - Baz!! | Foo - Rainbows $ http-music --clear --keep "Foo" --list-all Foo/ | Foo - Baz!! | Foo - Rainbows Note that "Song" wasn't in the second listing, since we didn't \`keep\` that back after \`clear\`ing the active playlist.