GithubHelp home page GithubHelp logo

maszaa / heos-scrobbler Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 239 KB

Update now playing and scrobble tracks listened with HEOS device to Last.fm.

License: MIT License

Dockerfile 0.96% JavaScript 51.04% Python 40.16% Shell 7.84%
heos lastfm scrobble

heos-scrobbler's Introduction

HEOS scrobbler

Update now playing and scrobble tracks listened with HEOS device to Last.fm. Tracks to be scrobbled must have artist and title in metadata.

Requirements: Docker, Docker-Compose, Last.fm account & API account (create later here: https://www.last.fm/api/account/create)

  1. Create .env files in subdirectories based on example.env files.
  2. ./start.sh
  3. After the stack has started, visit <YOUR_MONGO_EXPRESS_HOST>:<YOUR_MONGO_EXPRESS_PORT> using the username and password you've set and at heosScrobbler.heosPlayers setup players and their configuration you want to use for scrobbling. You do not need to restart the stack.
  4. Same address, at heosScrobbler.lastFmUsers select the pre-populated user, input your Last.fm username and password and save. heos-track-scrobbler will generate a Last.fm session key for your account and delete the password from the database next time it attempts to scrobble (i.e. you've listened a track with your HEOS device). When you change your Last.fm user configuration you don't have to restart the stack

You can create custom event handlers and listeners for HEOS connections at heos-track-listener/heos/additional. Files ending with .js will be loaded during startup. Your handlers and listeners must take the HEOS connetion and optionally now playing listener as parameters. Take a look at the example.js.txt at that path.

You can define track sources to be ignored by inserting substrings of sources to ignoreSources array of a player document. Substrings are case insensitive. If the source (case insensitive) of the new track contains any of the defined substrings it will not be saved (i.e. scrobbled).

heos-scrobbler's People

Contributors

dependabot[bot] avatar maszaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

heos-scrobbler's Issues

Web control

  • Session key based Last.fm authorization
  • MongoDB to store scrobble & player configurations and now playing data
  • mongo-express to visualize MongoDB

Authentication failed

Thanks for this project!

Fresh setup on WSL2 with all passwords correct, I get AuthenticationFailed errors on heos-track-listener:

WARNING: The MONGO_PORT variable is not set. Defaulting to a blank string.
WARNING: The REDIS_PORT variable is not set. Defaulting to a blank string.
mongo uses an image, skipping
mongo-express uses an image, skipping
redis uses an image, skipping
Building heos-track-scrobbler
[+] Building 2.1s (11/11) FINISHED
 => [internal] load build definition from Dockerfile                                                               0.1s
 => => transferring dockerfile: 38B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.1s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/python:3.8-alpine                                               1.8s
 => [1/6] FROM docker.io/library/python:3.8-alpine@sha256:1a60a5c46701d33f1e136b7dfc2114db2c30c0582eeb94c19e1bc90  0.0s
 => [internal] load build context                                                                                  0.2s
 => => transferring context: 576B                                                                                  0.1s
 => CACHED [2/6] RUN pip install --upgrade pip                                                                     0.0s
 => CACHED [3/6] WORKDIR /usr/src                                                                                  0.0s
 => CACHED [4/6] COPY requirements.txt ./                                                                          0.0s
 => CACHED [5/6] RUN pip install -r requirements.txt                                                               0.0s
 => CACHED [6/6] COPY . ./                                                                                         0.0s
 => exporting to image                                                                                             0.0s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:dc8ab5d1dfb67083f20f09118445cd463aa81597cc2b149c1d88c43cb0809ec6                       0.0s
 => => naming to docker.io/library/heos-track-scrobbler:latest                                                     0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Building heos-track-listener
[+] Building 2.0s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                               0.1s
 => => transferring dockerfile: 37B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 34B                                                                                   0.0s
 => [internal] load metadata for docker.io/library/node:12-alpine                                                  1.7s
 => [internal] load build context                                                                                  0.1s
 => => transferring context: 619B                                                                                  0.1s
 => [1/5] FROM docker.io/library/node:12-alpine@sha256:1ea5900145028957ec0e7b7e590ac677797fa8962ccec4e73188092f7b  0.0s
 => CACHED [2/5] WORKDIR /usr/src                                                                                  0.0s
 => CACHED [3/5] COPY package.json package-lock.json ./                                                            0.0s
 => CACHED [4/5] RUN npm install --only=production                                                                 0.0s
 => CACHED [5/5] COPY . ./                                                                                         0.0s
 => exporting to image                                                                                             0.0s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:74e568df85c975957a31c3c87e596493c5ab2a4831ceb314115e64369e41c8c3                       0.0s
 => => naming to docker.io/library/heos-track-listener:latest                                                      0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Creating heos-scrobbler_mongo_1 ... done
Creating heos-scrobbler_redis_1 ... done
Creating heos-scrobbler_mongo-express_1 ... done
Creating heos-scrobbler_heos-track-scrobbler_1 ... done
Creating heos-scrobbler_heos-track-listener_1  ... done
Attaching to heos-scrobbler_heos-track-listener_1, heos-scrobbler_heos-track-scrobbler_1
heos-track-scrobbler_1  | Error occured while getting user Traceback (most recent call last):
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 1394, in _get_socket
heos-track-scrobbler_1  |     sock_info = self.sockets.popleft()
heos-track-scrobbler_1  | IndexError: pop from an empty deque
heos-track-scrobbler_1  |
heos-track-scrobbler_1  | During handling of the above exception, another exception occurred:
heos-track-scrobbler_1  |
heos-track-scrobbler_1  | Traceback (most recent call last):
heos-track-scrobbler_1  |   File "/usr/src/last_fm/last_fm_scrobbler.py", line 14, in get_user
heos-track-scrobbler_1  |     last_fm_user = LastFmUser.objects().first()
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/mongoengine/queryset/base.py", line 287, in first
heos-track-scrobbler_1  |     result = queryset[0]
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/mongoengine/queryset/base.py", line 191, in __getitem__
heos-track-scrobbler_1  |     queryset._cursor[key],
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/cursor.py", line 692, in __getitem__
heos-track-scrobbler_1  |     for doc in clone:
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/cursor.py", line 1238, in next
heos-track-scrobbler_1  |     if len(self.__data) or self._refresh():
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/cursor.py", line 1155, in _refresh
heos-track-scrobbler_1  |     self.__send_message(q)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/cursor.py", line 1044, in __send_message
heos-track-scrobbler_1  |     response = client._run_operation(
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1424, in _run_operation
heos-track-scrobbler_1  |     return self._retryable_read(
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1518, in _retryable_read
heos-track-scrobbler_1  |     with self._secondaryok_for_server(
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__
heos-track-scrobbler_1  |     return next(self.gen)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1371, in _secondaryok_for_server
heos-track-scrobbler_1  |     with self._get_socket(server, session) as sock_info:
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__
heos-track-scrobbler_1  |     return next(self.gen)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1308, in _get_socket
heos-track-scrobbler_1  |     with server.get_socket(
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__
heos-track-scrobbler_1  |     return next(self.gen)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 1331, in get_socket
heos-track-scrobbler_1  |     sock_info = self._get_socket(all_credentials)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 1397, in _get_socket
heos-track-scrobbler_1  |     sock_info = self.connect(all_credentials)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 1297, in connect
heos-track-scrobbler_1  |     sock_info.check_auth(all_credentials)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 820, in check_auth
heos-track-scrobbler_1  |     self.authenticate(credentials)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 837, in authenticate
heos-track-scrobbler_1  |     auth.authenticate(credentials, self)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/auth.py", line 672, in authenticate
heos-track-scrobbler_1  |     auth_func(credentials, sock_info)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/auth.py", line 590, in _authenticate_default
heos-track-scrobbler_1  |     return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/auth.py", line 295, in _authenticate_scram
heos-track-scrobbler_1  |     res = sock_info.command(source, cmd)
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/pool.py", line 710, in command
heos-track-scrobbler_1  |     return command(self, dbname, spec, secondary_ok,
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/network.py", line 158, in command
heos-track-scrobbler_1  |     helpers._check_command_response(
heos-track-scrobbler_1  |   File "/usr/local/lib/python3.8/site-packages/pymongo/helpers.py", line 167, in _check_command_response
heos-track-scrobbler_1  |     raise OperationFailure(errmsg, code, response, max_wire_version)
heos-track-scrobbler_1  | pymongo.errors.OperationFailure: Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}
heos-track-scrobbler_1  |  Could not save document (Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'})
heos-track-listener_1   |
heos-track-listener_1   | > [email protected] start /usr/src
heos-track-listener_1   | > node --unhandled-rejections=strict index.js
heos-track-listener_1   |
heos-track-listener_1   | /usr/src/node_modules/mongodb/lib/cmap/connection.js:272
heos-track-listener_1   |           callback(new MongoError(document));
heos-track-listener_1   |                    ^
heos-track-listener_1   |
heos-track-listener_1   | MongoError: Authentication failed.
heos-track-listener_1   |     at MessageStream.messageHandler (/usr/src/node_modules/mongodb/lib/cmap/connection.js:272:20)
heos-track-listener_1   |     at MessageStream.emit (events.js:314:20)
heos-track-listener_1   |     at processIncomingData (/usr/src/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
heos-track-listener_1   |     at MessageStream._write (/usr/src/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
heos-track-listener_1   |     at doWrite (_stream_writable.js:403:12)
heos-track-listener_1   |     at writeOrBuffer (_stream_writable.js:387:5)
heos-track-listener_1   |     at MessageStream.Writable.write (_stream_writable.js:318:11)
heos-track-listener_1   |     at Socket.ondata (_stream_readable.js:718:22)
heos-track-listener_1   |     at Socket.emit (events.js:314:20)
heos-track-listener_1   |     at addChunk (_stream_readable.js:297:12)
heos-track-listener_1   |     at readableAddChunk (_stream_readable.js:272:9)
heos-track-listener_1   |     at Socket.Readable.push (_stream_readable.js:213:10)
heos-track-listener_1   |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
heos-track-listener_1   |   ok: 0,
heos-track-listener_1   |   code: 18,
heos-track-listener_1   |   codeName: 'AuthenticationFailed'
heos-track-listener_1   | }
heos-track-listener_1   | npm ERR! code ELIFECYCLE
heos-track-listener_1   | npm ERR! errno 1
heos-track-listener_1   | npm ERR! [email protected] start: `node --unhandled-rejections=strict index.js`
heos-track-listener_1   | npm ERR! Exit status 1
heos-track-listener_1   | npm ERR!
heos-track-listener_1   | npm ERR! Failed at the [email protected] start script.
heos-track-listener_1   | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
heos-track-listener_1   |
heos-track-listener_1   | npm ERR! A complete log of this run can be found in:
heos-track-listener_1   | npm ERR!     /root/.npm/_logs/2021-10-01T09_04_57_857Z-debug.log
heos-track-listener_1   |
heos-track-listener_1   | > [email protected] start /usr/src
heos-track-listener_1   | > node --unhandled-rejections=strict index.js
heos-track-listener_1   |
heos-track-listener_1   | /usr/src/node_modules/mongodb/lib/cmap/connection.js:272
heos-track-listener_1   |           callback(new MongoError(document));
heos-track-listener_1   |                    ^
heos-track-listener_1   |
heos-track-listener_1   | MongoError: Authentication failed.
heos-track-listener_1   |     at MessageStream.messageHandler (/usr/src/node_modules/mongodb/lib/cmap/connection.js:272:20)
heos-track-listener_1   |     at MessageStream.emit (events.js:314:20)
heos-track-listener_1   |     at processIncomingData (/usr/src/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
heos-track-listener_1   |     at MessageStream._write (/usr/src/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
heos-track-listener_1   |     at doWrite (_stream_writable.js:403:12)
heos-track-listener_1   |     at writeOrBuffer (_stream_writable.js:387:5)
heos-track-listener_1   |     at MessageStream.Writable.write (_stream_writable.js:318:11)
heos-track-listener_1   |     at Socket.ondata (_stream_readable.js:718:22)
heos-track-listener_1   |     at Socket.emit (events.js:314:20)
heos-track-listener_1   |     at addChunk (_stream_readable.js:297:12)
heos-track-listener_1   |     at readableAddChunk (_stream_readable.js:272:9)
heos-track-listener_1   |     at Socket.Readable.push (_stream_readable.js:213:10)
heos-track-listener_1   |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
heos-track-listener_1   |   ok: 0,
heos-track-listener_1   |   code: 18,
heos-track-listener_1   |   codeName: 'AuthenticationFailed'
heos-track-listener_1   | }
heos-track-listener_1   | npm ERR! code ELIFECYCLE
heos-track-listener_1   | npm ERR! errno 1
heos-track-listener_1   | npm ERR! [email protected] start: `node --unhandled-rejections=strict index.js`
heos-track-listener_1   | npm ERR! Exit status 1
heos-track-listener_1   | npm ERR!
heos-track-listener_1   | npm ERR! Failed at the [email protected] start script.
heos-track-listener_1   | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
heos-track-listener_1   |
heos-track-listener_1   | npm ERR! A complete log of this run can be found in:
heos-track-listener_1   | npm ERR!     /root/.npm/_logs/2021-10-01T09_04_58_894Z-debug.log
heos-scrobbler_heos-track-listener_1 exited with code 1

Any pointer on where I'm going wrong?

start.sh fails occasionally

docker volume ls | grep -q ${PROJECT_NAME}_mongo[^-express] occasionally returns with not 0 exit code though volume exists and due to that MongoDB initialize.js script fails (user is already created) and the stack fails to start.

CI

  • CI
  • Add audit and update packages

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.