MSW Open Music Project
A light weight personal music streaming platform.
Introduction
[TOC]
What it can do
-
Traverse the specified folder and index files whose extensions meet the requirements.
-
Listening network port. Return to the front-end web page and process API requests.
-
Call ffmpeg to transcode music or video.
-
Manage files' information in the database, including adding tags, comments, etc.
What it won't do
-
Modify your file.
-
Read music metadata (for example, composer, album, genre).
-
Detect file changes (Need to manually update the database).
ER Diagram
Entities Relationship Diagram
-
avatarentity may change in future rc version. -
The first time you run the program, the server will create an anonymous user with id 1. All users who are not logged in will be automatically logged in to this account.
-
tmpfsis store in memory, which will be empty everytime server restart.
How to build
Compile software from source code. If you use the pre-compiled version, you don’t need to do this.
Build the back-end server
make linux or make windows
The executable file is named msw-open-music or msw-open-music.exe
Build the font-end web pages
To build production web page make web
This command will go into web directory and install node_modules. Then execute npm run build command. The built web pages is under web/build directory.
To start the development, run cd web and npm start
Usage
Security Warning (v1.2.0-rc1):
The cookie stored in the client browser is encrypted using the environment variable "SESSION_KEY". The server will trust the client's cookie. Leaking this environment variable may cause security problems. This problem will be fixed in a future rc version.
Password is not hashed in database, which will be fixed in next rc version.
Start back-end server. Server will listen on 8080 port.
Build the font-end web page, then go to http://127.0.0.1:8080
By default:
- URL matched
/api/*will process by back-end server. - Others URL matched
/*will be served files underweb/build/
Run back-end server
Token authencation no longer support in v1.2.0 stable version.
Configuration file is config.json, Please modify your token 。
Default ffmpeg_threads is 1. Seems value larger than 1 will not increase the audio encode speed.
config.json description
database_namestring type. The filename ofsqlite3database. Will create if that file doesn't exist.addrstring type. The listen address and port.tokenstring type. Password.ffmpeg_config_listlist type, includeffmpegConfigobject.file_life_timeinteger type (second). Life time for temporary file. If the temporary file is not accessed for more than this time, back-end server will delete this file.cleaner_internalinteger type (second). Interval fortmpfschecking temporary file.rootstring type. Directory to store temporary files. Default is/tmp, please modify this directory if you are using Windows.
Run font-end web page
Open your web browser to http://127.0.0.1:8080 you will see the web pages.
Setup the first admin account
The first administrator account will be active automatically, other administrator accounts need active manually.
Go to register page, select the role to admin, and register the first admin account.
About tmpfs
If the Prepare mode is enabled in the font-wed player, back-end server will convert the whole file into the temporary folder, then serve file using native method. This cqan avoid ffmpeg pipe break problem cause by unstable network connection while streaming audio.
The default temporary folder is /tmp, which is a tmpfs file system in Linux operating system. Default life time for temporary files is 600 seconds (10 minutes). If the temporary file is not accessed for more than this time, back-end server will delete this file.
Change log
v1.0.0First version. Ready to use in production environment.v1.1.0UseReactto rewrite the font-end web pages (Previous usingVue).v1.2.0Add user, tag, review, video functions for DBMS course work.
Back-end API references
API does not need to respond any data will return the following JSON object.
{
"status": "OK"
}
Sometime errors happen, server will return the following JSON object, which error is the detailed error message.
{
"error": "Wrong password"
}
API does not need to send any data should use GET method, otherwise use POST method.
Server use cookies to authencate a user. Any request without cookies will be consider from an anonymouse user.
Some import source code file:
-
pkg/api/api.godefine URL -
pkg/database/sql_stmt.godefine SQL queries and do the init job. -
pkg/database/struct.godefine JSON structures for database entities.
Font-end web pages
-
/#/Get random files. -
/#/filesSearch files. -
/#/files/39Information of the which id is 39. -
/#/files/39/reviewReviews of the file with file id 39. -
/#/files/39/shareShare page with the file id 39. -
/#/foldersSearch folders. -
/#/folders/2614Files in folder which id is 2614. -
/#/manageManage page. -
/#/manage/usersList users. -
/#/manage/users/1Information of user whose id is 1. -
/#/manage/tagsList tags. -
/#/manage/tags/1Information of tag which id is 1. -
/#/manage/feedbacksList feedbacks.

