IrosTheBeggar / mStream

The easiest music streaming server available
http://mstream.io
GNU General Public License v3.0
2.21k stars 186 forks source link

Auto DJ doesn't work #348

Open MykolaMorhun opened 2 years ago

MykolaMorhun commented 2 years ago

Steps to reproduce

  1. Login to your mStream user account (non-admin)
  2. Click on Auto DJ button (bottom right corner). Nothing happens.

Logs

2021-11-25T19:04:11.584Z error: Server error on route /api/v1/db/random-songs
Nov 25 19:04:11 hostname node[7114]: WebError: No songs that match criteria
Nov 25 19:04:11 hostname node[7114]:     at mstream.post (/home/username/mStream/src/api/db.js:394:30)
Nov 25 19:04:11 hostname node[7114]:     at Layer.handle [as handle_request] (/home/username/mStream/node_modules/express/lib/router/layer.js:95>
Nov 25 19:04:11 hostname node[7114]:     at next (/home/username/mStream/node_modules/express/lib/router/route.js:137:13)
Nov 25 19:04:11 hostname node[7114]:     at Route.dispatch (/home/username/mStream/node_modules/express/lib/router/route.js:112:3)
Nov 25 19:04:11 hostname node[7114]:     at Layer.handle [as handle_request] (/home/username/mStream/node_modules/express/lib/router/layer.js:95>
Nov 25 19:04:11 hostname node[7114]:     at /home/username/mStream/node_modules/express/lib/router/index.js:281:22
Nov 25 19:04:11 hostname node[7114]:     at Function.process_params (/home/username/mStream/node_modules/express/lib/router/index.js:335:12)
Nov 25 19:04:11 hostname node[7114]:     at next (/home/username/mStream/node_modules/express/lib/router/index.js:275:10)
Nov 25 19:04:11 hostname node[7114]:     at mstream.use (/home/username/mStream/src/api/auth.js:87:5)
Nov 25 19:04:11 hostname node[7114]:     at Layer.handle [as handle_request] (/home/username/mStream/node_modules/express/lib/router/layer.js:95>

Investigation

When try to get https://hostname:2222/api/v1/db/random-songs it returns 401 error:

{"error":"Authentication Error"}

However, I am actually logged in and can play tracks (clicking on back button in browser returns to the web interface from where I can play tracks without any issue).

Versions

5.8.1 (logs taken from) 5.7.2 Maybe some older versions too, haven't checked.

Installation method

  1. Clone sources, checkout tag
  2. Run npm install
  3. Run the server

Configuration

Show config.json ```json { "port": 2222, "webAppDirectory": "/home/username/mStream/webapp", "writeLogs": false, "storage": { "logsDirectory": "/tmp/mstream-logs" }, "noUpload": true, "scanOptions": { "skipImg": true, "scanInterval": 0, "pause": 50, "saveInterval": 5000, "bootScanDelay": 5 }, "folders": { "tracks": { "root": "/home/username/music" } }, "transcode": { "enabled": false, "ffmpegDirectory": "/path/to/ffmpeg-dir", "defaultCodec": "opus", "defaultBitrate": "128k" }, "secret": "hidden", "users": { "admin": { "vpaths": [ "tracks" ], "password": "hidden-password-1", "salt": "hidden-salt-1", "admin": true, "username": "admin" }, "user": { "vpaths": [ "tracks" ], "password": "hidden-password-2", "salt": "hidden-salt-2", "admin": false } }, "ssl": { "key": "/letsencrypt/privkey.pem", "cert": "/letsencrypt/cert.pem" } } ```
IrosTheBeggar commented 2 years ago

The error you are getting is the 'No songs that match criteria' error. This only happens when the db search to find a random song returns an empty set.

I was able to reproduce this by setting the AutoDJ to only used rated songs after starting with a fresh DB. Can you check the AutoDJ panel and make sure all the settings look OK. It remembers what settings you used last btw.

If that's not the issue, can you use the dev tools to see the data that is being sent to the /random-songs endpoint?

MykolaMorhun commented 2 years ago

Thank you @IrosTheBeggar for the answer. I have default settings in Auto DJ: Under Use Folders item tracks is ticked (the only possible option) and the Minimum Rating is set to Disabled.

If that's not the issue, can you use the dev tools to see the data that is being sent to the /random-songs endpoint?

Endpoint: https://hostname:1234/api/v1/db/random-songs Request data: {"ignoreList":[],"minRating":0,"ignoreVPaths":{}} Status: 400 Bad Request Response data: error: "No songs that match criteria"

If you need more data or investigation from my side, please let me know, I'll be glad to do it.

MykolaMorhun commented 2 years ago

The strange thing is that the db is empty (no user data in it).

Show db JSON ```json { "filename": "/path/to/mStream/save/db/shared.loki-v1.db", "collections": [ { "name": "playlists", "data": [], "idIndex": [], "binaryIndices": {}, "constraints": null, "uniqueNames": [], "transforms": {}, "objType": "playlists", "dirty": false, "cachedIndex": null, "cachedBinaryIndex": null, "cachedData": null, "adaptiveBinaryIndices": true, "transactional": false, "cloneObjects": false, "cloneMethod": "parse-stringify", "asyncListeners": false, "disableMeta": false, "disableChangesApi": true, "disableDeltaChangesApi": true, "autoupdate": false, "serializableIndices": true, "disableFreeze": true, "ttl": null, "maxId": 0, "DynamicViews": [], "events": { "insert": [], "update": [], "pre-insert": [], "pre-update": [], "close": [], "flushbuffer": [], "error": [], "delete": [ null ], "warning": [ null ] }, "changes": [], "dirtyIds": [] } ], "databaseVersion": 1.5, "engineVersion": 1.5, "autosave": false, "autosaveInterval": 5000, "autosaveHandle": null, "throttledSaves": true, "options": { "serializationMethod": "normal", "destructureDelimiter": "$<\n" }, "persistenceMethod": "fs", "persistenceAdapter": null, "verbose": false, "events": { "init": [ null ], "loaded": [], "flushChanges": [], "close": [], "changes": [], "warning": [] }, "ENV": "NODEJS" } ```

mStream has permissions to read all the tracks.