Skip to main content

Gather Scrobble - Scrobble your last.fm or Spotify activity to the Gather status.

Project description

Inspired by gathertown/mod-spotify-as-status.

Scrobble your last.fm or Spotify activity to the Gather status.

gather-scrobble

gather-scrobble

gather-status

gather-status

Installation

pip install gather-scrobble

As this library has a CLI, you may have permissions issues when installing, so try it with the --user flag:

pip install gather-scrobble --user

Documentation

Configuration

Itโ€™s necessary to configure the following credentials:

Gather Credentials

Access Gather API keis to get your API_KEY.

last.fm Credentials

If you will scrobble from last.fm.

Create a last.fm API account to get your API_KEY and API_SECRET.

Spotify Credentials

If you will scrobble from Spotify.

Access your Spotify account dashboard and create a new app (in case you donโ€™t have one or do not want to use an existing one). And get your CLIENT_ID and CLIENT_SECRET.

Also add a redirect URI in the Edit Settings. Suggested value: http://127.0.0.1:9090.

The spotispy will instantiate a server to receive the access token. More info here.

You can configure your credentials in 4 ways and with respective priorities:

environment variables

export GATHER_API_KEY=<GATHER_API_KEY>
export LASTFM_API_KEY=<LASTFM_API_KEY>
export LASTFM_API_SECRET=<LASTFM_API_SECRET>
export LASTFM_USERNAME=<LASTFM_USERNAME>
export SPOTIFY_CLIENT_ID=<SPOTIFY_CLIENT_ID>
export SPOTIFY_CLIENT_SECRET=<SPOTIFY_CLIENT_SECRET>
export SPOTIFY_CLIENT_REDIRECT_URI=<SPOTIFY_CLIENT_REDIRECT_URI>

.ini file

[settings]
GATHER_API_KEY=<GATHER_API_KEY>
LASTFM_API_KEY=<LASTFM_API_KEY>
LASTFM_API_SECRET=<LASTFM_API_SECRET>
LASTFM_USERNAME=<LASTFM_USERNAME>
SPOTIFY_CLIENT_ID=<SPOTIFY_CLIENT_ID>
SPOTIFY_CLIENT_SECRET=<SPOTIFY_CLIENT_SECRET>
SPOTIFY_CLIENT_REDIRECT_URI=<SPOTIFY_CLIENT_REDIRECT_URI>

.env file

GATHER_API_KEY=<GATHER_API_KEY>
LASTFM_API_KEY=<LASTFM_API_KEY>
LASTFM_API_SECRET=<LASTFM_API_SECRET>
LASTFM_USERNAME=<LASTFM_USERNAME>
SPOTIFY_CLIENT_ID=<SPOTIFY_CLIENT_ID>
SPOTIFY_CLIENT_SECRET=<SPOTIFY_CLIENT_SECRET>
SPOTIFY_CLIENT_REDIRECT_URI=<SPOTIFY_CLIENT_REDIRECT_URI>

Usage

Help

gather-scrobble --help
Gather Scrobble v0.1.1
    Usage:
        gather-scrobble start <space_id> [--source SOURCE] [--emojis EMOJIS]
        gather-scrobble info
        gather-scrobble test <space_id>

    Arguments:
        <space_id>          Gather space id.

    Options:
        -h --help           Show this screen.
        -s --source SOURCE  Scrobble source, if not defined the tool will try
                            all available sources configured.
                            Can be: lastfm, spotify, or any.
                            If 'any' it will use the first source configured in
                            the priority: lastfm -> spotify [default: any]
        -e --emojis EMOJIS  It is possible to customize the emojis, by setting
                            the list of emojis that will be chosen randomly,
                            and also you don't like emojis, you can set an
                            empty string here. [default: ๐ŸŽผ๐ŸŽต๐ŸŽถ๐ŸŽง๐Ÿ“ป๐ŸŽท๐ŸŽธ๐ŸŽน]
        -v --verbose        Enable verbose logging.

Info

Before starting, check if you have configured the services:

gather-scrobble info
Gather Scrobble
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Service   โ”ƒ Configured   โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Gather    โ”ƒ True         โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ last.fm   โ”ƒ True         โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Spotify   โ”ƒ False        โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›

Test

And test your configuration:

gather-scrobble test "aAa0aAaAaaA0Aaaa/Name"
Testing connection with Gather...
Success
Testing connection with last.fm...
Success
Testing connection with Spotify...
Success

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Service   โ”ƒ Working?   โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Gather    โ”ƒ True       โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ last.fm   โ”ƒ True       โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Spotify   โ”ƒ True       โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›

Start

The first time you scrobble for any of the sources, the user will be asked to authorize your application to access data from the respective scrobble sources.

gather-scrobble start "aAa0aAaAaaA0Aaaa/Name"
๐ŸŽธ - Evil Papagali - Massacration ๐„›๐„™๐„˜๐„›๐„™

Verbose

The start and test commands accept an optional flag -v or --verbose to show more detailed information about the execution:

[2024-07-27 13:29:24,850][DEBUG] Loading credentials
[2024-07-27 13:29:25,144][DEBUG] Starting application
[2024-07-27 13:29:25,769][INFO] Connected to wss://ip-00-000-00-000.sa-east-1-a.prod.aws.gather.town:443/
[2024-07-27 13:29:26,084][INFO] Connected as user a0000bC0DEFgjIjLmnoPqRSTuvxY
[2024-07-27 13:29:26,085][DEBUG] Receiving messages
[2024-07-27 13:29:26,086][DEBUG] Heartbeat sent
[2024-07-27 13:29:26,086][DEBUG] Application started
[2024-07-27 13:29:26,540][DEBUG] New Status: ๐Ÿ“ป - Junior's Eyes - Black Sabbath
[2024-07-27 13:29:26,639][DEBUG] Message received: events {
  transactionStatus {
    txnId: 2550000000
    succeeded: true
  }
}
events {
  transactionStatus {
    txnId: 900000000
    succeeded: true
  }
}

^Cbye

Docker

Pull

docker pull pyanderson/gather-scrobble:0.1.1

Docker Configuration

Keyring

The most common way to manage credentials in docker containers is through environment variables, but in this case, you can still use keyring, through the third-party keyrings.cryptfile, you will need to create a file with your credentials, mount a volume with the file in the path /root/.local/share/python_keyring/cryptfile_pass.cfg and set the KEYRING_CRYPTFILE_PASSWORD environment variable with the password that you used to create the file:

docker run -v $(echo $HOME)/.local/share/python_keyring/cryptfile_pass.csg:/root/.local/share/python_keyring/cryptfile_pass.cfg -e KEYRING_CRYPTFILE_PASSWORD=secret_password ...

Env File

Add your credentials to a .env file and use it with the โ€“env-file option:

docker run --env-file /path/to/myfile.env ...

Cache

To avoid being asked to authorize the last.fm/Spotify application in every usage, you should mount a volume to save the gather-scrobble cache folder:

docker run -v /path/to/the/host/cache/folder:/root/.config

Docker Usage

The docker container works as an executable, so you can use the same CLI command interface, for example, to test your configuration you can do this:

docker run --env-file /path/to/myfile.env -v /path/to/the/host/cache/folder:/root/.config -it pyanderson/gather-scrobble:0.1.1 test "aAa0aAaAaaA0Aaaa/Name"
Testing connection with Gather...
Success
Testing connection with last.fm...
Success
Testing connection with Spotify...
Success

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Service   โ”ƒ Working?   โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Gather    โ”ƒ True       โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ last.fm   โ”ƒ True       โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Spotify   โ”ƒ True       โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›

Examples

Validate your credentials:

docker run -it --rm --name gather-scrobble --env-file /path/to/myfile.env -v /path/to/the/host/cache/folder:/root/.config pyanderson/gather-scrobble:0.1.1 test "aAa0aAaAaaA0Aaaa/Name"
Testing connection with Gather...
Success
Testing connection with last.fm...
Please authorize this script to access your account: https://www.last.fm/api/auth/?api_key=<api_key>
Success
Testing connection with Spotify...
Go to the following URL: https://accounts.spotify.com/authorize?client_id=<client_id>&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A9090&scope=user-read-currently-playing+user-read-playback-state
Enter the URL you were redirected to: http://127.0.0.1:9090/?code=<code>
Success

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Service   โ”ƒ Working?   โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Gather    โ”ƒ True       โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ last.fm   โ”ƒ True       โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ Spotify   โ”ƒ True       โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›

Run gather-scrobble in background:

docker run -d --restart=always --name gather-scrobble --env-file /path/to/myfile.env -v /path/to/the/host/cache/folder:/root/.config pyanderson/gather-scrobble:0.1.1 start "aAa0aAaAaaA0Aaaa/Name"
cbe4b6c916d8e7977788462a447b8a6c9e526f46f5c9b85d7be5f843e7fd80dc

Check the logs:

docker logs -f gather-scrobble
[2023-04-29 15:39:30,637][DEBUG] loading credentials
[2023-04-29 15:39:31,427][DEBUG] starting application
[2023-04-29 15:39:32,925][DEBUG] application started
[2023-04-29 15:40:05,650][DEBUG] ๐ŸŽผ - Madhouse - Anthrax

Stop:

docker rm -r gather-scrobble
gather-scrobble

Docker Compose

Thanks to @chocoelho for the docker compose example.

compose.yaml:

services:
  main:
    image: "pyanderson/gather-scrobble:0.1.1"
    command: start $${GATHER_SPACE_ID} -v
    restart: always
    env_file:
      - .env
    volumes:
      - .cache:/root/.config/gather-scrobble

Validate the credentials:

docker compose run --rm main test "aAa0aAaAaaA0Aaaa/Name"

Run in the detached mode:

docker compose up -d service

Logs:

docker compose logs service

FAQ

  • How to get the space_id value? First enter in the space you want to scrobble, the space_id will be in the URL after the /app/. E.g., in the URL โ€œhttps://app.gather.town/app/aAa0aAaAaaA0Aaaa/Nameโ€ the space_id is aAa0aAaAaaA0Aaaa/Name.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gather-scrobble-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

gather_scrobble-0.1.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file gather-scrobble-0.1.1.tar.gz.

File metadata

  • Download URL: gather-scrobble-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.19

File hashes

Hashes for gather-scrobble-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e6f0104e86f168cee3b9b6dac1395177d112a27d877ec98287bf060b594921c2
MD5 e9c1b2cd48844c2f078c9be5289bfe6a
BLAKE2b-256 323951e20b87b5e9bf9aaef1c2ae8177a08c14b78ee30694981cdb7b2c37ae6a

See more details on using hashes here.

File details

Details for the file gather_scrobble-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gather_scrobble-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3900f3a4b171e22407ac1773fed9d45aa193bc4333b7340ba08477594b67b500
MD5 8357fe192eaca5005c2874dbb066a394
BLAKE2b-256 c934b4f4948dc8bcfb647f3a140bbeabddeb4eb42228cdf458186839c38a1d89

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page