mirror of
https://github.com/IrosTheBeggar/mStream.git
synced 2025-10-27 07:31:02 +00:00
Cleanup and doc search and download endpoints
This commit is contained in:
parent
0a53621b43
commit
7879fb52b3
@ -62,6 +62,8 @@ http://yourserver.com/vPath/filepath/song.mp3?token=XXXXXXXX
|
||||
|
||||
#### Database Read (Albums/Artists/Etc)
|
||||
|
||||
[/db/search](API/db_search.md)
|
||||
|
||||
[/db/albums](API/db_albums.md)
|
||||
|
||||
[/db/artists](API/db_artists.md)
|
||||
@ -71,6 +73,7 @@ http://yourserver.com/vPath/filepath/song.mp3?token=XXXXXXXX
|
||||
[/jukebox/push-to-client.md](API/jukebox_push-to-client.md)
|
||||
|
||||
#### Download
|
||||
[/download](API/download.md)
|
||||
|
||||
#### Shared
|
||||
|
||||
|
||||
37
docs/API/db_search.md
Normal file
37
docs/API/db_search.md
Normal file
@ -0,0 +1,37 @@
|
||||
**Search DB **
|
||||
----
|
||||
Retrieves albums and artists that much a given string
|
||||
|
||||
* **URL**
|
||||
|
||||
/db/search
|
||||
|
||||
* **Method:**
|
||||
|
||||
`POST`
|
||||
|
||||
* **JSON Params**
|
||||
|
||||
**Required:**
|
||||
|
||||
`search` - String that will be searched for
|
||||
|
||||
* **JSON Example**
|
||||
|
||||
```
|
||||
{
|
||||
'search': 'The Offsp'
|
||||
}
|
||||
```
|
||||
|
||||
* **Success Response:**
|
||||
|
||||
* **Code:** 200 <br />
|
||||
**Content:**
|
||||
|
||||
```
|
||||
{
|
||||
"albums":[album1, album2],
|
||||
"artists":[artist1, artist2, artist3]
|
||||
}
|
||||
```
|
||||
25
docs/API/download.md
Normal file
25
docs/API/download.md
Normal file
@ -0,0 +1,25 @@
|
||||
**Download Files**
|
||||
----
|
||||
Will zip files up and them download the zip file
|
||||
|
||||
* **URL**
|
||||
|
||||
/download
|
||||
|
||||
* **Method:**
|
||||
|
||||
`POST`
|
||||
|
||||
* **Params**
|
||||
|
||||
The download endpoint gets the list of files to download through the POST param `fileArray`. The reason for this is due to the finicky way some browsers handle downloads.
|
||||
|
||||
* **JSON Example**
|
||||
|
||||
```
|
||||
['path/to/file1.mp3', path/to/file2.flac]
|
||||
```
|
||||
|
||||
* **Success Response:**
|
||||
|
||||
Will download a zip file
|
||||
0
docs/cli_arguments.md
Normal file
0
docs/cli_arguments.md
Normal file
17
docs/docker.md
Normal file
17
docs/docker.md
Normal file
@ -0,0 +1,17 @@
|
||||
#### Using Docker
|
||||
|
||||
Download the Dockerfile, or clone the repository, then run the following
|
||||
commands:
|
||||
|
||||
```shell
|
||||
docker build -t local/mstream .
|
||||
|
||||
docker run --rm -v /path/to/my/music:/music local/mstream
|
||||
```
|
||||
|
||||
The ENTRYPOINT is `mstream`, so you can use the same option as if using the
|
||||
default installation.
|
||||
|
||||
```shell
|
||||
docker run --rm -v /path/to/my/music:/music local/mstream -l -u username -x password
|
||||
```
|
||||
50
docs/install.md
Normal file
50
docs/install.md
Normal file
@ -0,0 +1,50 @@
|
||||
## Install on Ubuntu
|
||||
|
||||
**Dependencies**
|
||||
|
||||
mStream has the following dependencies:
|
||||
|
||||
* NodeJS and NPM
|
||||
* Python 2
|
||||
* GCC and G++
|
||||
* node-gyp
|
||||
|
||||
**Install NodeJS**
|
||||
|
||||
```shell
|
||||
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nodejs
|
||||
```
|
||||
|
||||
**Install GCC and node-gyp**
|
||||
|
||||
```shell
|
||||
sudo apt-get install -y build-essential
|
||||
sudo npm install -g node-gyp
|
||||
```
|
||||
|
||||
**Install mStream**
|
||||
|
||||
Install through NPM
|
||||
|
||||
```shell
|
||||
sudo npm install -g mstream
|
||||
|
||||
cd /path/to/your/music
|
||||
mstream
|
||||
```
|
||||
|
||||
Or Install through Git
|
||||
|
||||
```shell
|
||||
git clone https://github.com/IrosTheBeggar/mStream.git
|
||||
|
||||
cd mStream
|
||||
|
||||
npm install
|
||||
|
||||
sudo npm link
|
||||
```
|
||||
|
||||
Test it by running `mstream` in the terminal. Make sure it's working by checking out http://localhost:3000/
|
||||
@ -136,7 +136,7 @@ exports.setup = function(mstream, dbSettings){
|
||||
|
||||
|
||||
mstream.post('/db/search', function(req, res){
|
||||
var searchTerm = "%" + req.body.search + "%" ;
|
||||
var searchTerm = "%" + req.parsedJSON.search + "%" ;
|
||||
|
||||
var returnThis = {"albums":[], "artists":[]};
|
||||
|
||||
|
||||
@ -132,14 +132,13 @@ exports.setup = function(mstream, dbSettings){
|
||||
// Delete playlist from DB
|
||||
db.run("DELETE FROM mstream_playlists WHERE playlist_name = ? AND user = ?;", [playlistname, req.user.username], function(){
|
||||
res.send('{success: true}');
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mstream.post('/db/search', function(req, res){
|
||||
var searchTerm = "%" + req.body.search + "%" ;
|
||||
var searchTerm = "%" + req.parsedJSON.search + "%" ;
|
||||
|
||||
var returnThis = {"albums":[], "artists":[]};
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
exports.setup = function(mstream, program){
|
||||
const archiver = require('archiver'); // Zip Compression
|
||||
const fe = require('path');
|
||||
|
||||
|
||||
|
||||
// Download a zip file of music
|
||||
mstream.post('/download', function (req, res){
|
||||
@ -38,7 +38,7 @@ exports.setup = function(mstream, program){
|
||||
var fileString = fileArray[i];
|
||||
|
||||
// TODO: Add file by ataching user's musicdir to the relative directory supplied
|
||||
archive.file(fe.normalize( fileString), { name: fe.basename(fileString) });
|
||||
archive.file(fe.join( req.user.musicDir, fileString), { name: fe.basename(fileString) });
|
||||
}
|
||||
|
||||
archive.finalize();
|
||||
|
||||
@ -1102,9 +1102,9 @@ $("#filelist").on('click', '.playlistz', function() {
|
||||
if($(this).val().length>1){
|
||||
|
||||
var request = $.ajax({
|
||||
url: "db/search",
|
||||
url: "/db/search",
|
||||
type: "POST",
|
||||
data: { search : $(this).val() },
|
||||
data: { json: JSON.stringify({ search: $(this).val() })},
|
||||
});
|
||||
|
||||
request.done(function( msg ) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user