+20
README.md
+20
README.md
···
1
+
# Rocksky Auto-scrobbler
2
+
3
+
A command-line program/service to automatically scrobble your music listening to [Rocksky](https://rocksky.app)!
4
+
5
+
## Prerequisites
6
+
7
+
You'll need the following pre-installed:
8
+
9
+
* [media-control](https://github.com/ungive/media-control)
10
+
* [jq](https://jqlang.org/)
11
+
12
+
I guess also bash. You probably have bash.
13
+
14
+
## Installation
15
+
16
+
From the folder, run `install.sh`, probably either as an admin user or as long as you know the sudo password. Once you've done that, it'll be running, and always run on startup.
17
+
18
+
## Pausing/Uninstalling
19
+
20
+
If you need to turn off the scrobbler, run `systemctl stop rocksky-autoscrobble`. (In this case, it will restart when your computer does, or when you restart the service.) If you need to disable it indefinitely, run `systemctl disable rocksky-autoscrobble.service`.
+11
install.sh
+11
install.sh
···
1
+
#!/usr/bin/env bash
2
+
3
+
sudo chmod +x scrobble.sh
4
+
sudo cp scrobble.sh /usr/bin/local
5
+
if [[ "$OSTYPE" == "darwin*" ]]; then
6
+
sudo cp rocksky-autoscrobble.plist ~/Library/LaunchAgents
7
+
else
8
+
sudo cp rocksky-autoscrobble.service /lib/systemd/system
9
+
sudo systemctl enable rocksky-autoscrobble.service
10
+
sudo systemctl start rocksky-autoscrobble.service
11
+
fi
+10
rocksky-autoscrobble.plist
+10
rocksky-autoscrobble.plist
···
1
+
<?xml version="1.0" encoding="UTF-8"?>
2
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+
<plist version="1.0">
4
+
<dict>
5
+
<key>Label</key>
6
+
<string>sh.birdwrongs.rockskyautoscrobbler</string>
7
+
<key>KeepAlive</key>
8
+
<true/>
9
+
</dict>
10
+
</plist>
+8
rocksky-autoscrobble.service
+8
rocksky-autoscrobble.service
+15
scrobble.sh
+15
scrobble.sh
···
1
+
#!/usr/bin/env bash
2
+
3
+
index=0; media-control stream | \
4
+
while IFS= read -r line; do \
5
+
musicapp=$(jq -e '.payload.isMusicApp' <<< $line); \
6
+
if [ "$musicapp" = true ]; then \
7
+
title=$(jq -e '.payload.title' <<< $line); \
8
+
artist=$(jq -e '.payload.artist' <<< $line); \
9
+
if [ "$title" >/dev/null != null ]; then \
10
+
eval "rocksky scrobble $title $artist"; \
11
+
echo "rocksky scrobble $title $artist"; \
12
+
echo "rocksky scrobble $title $artist" >> cronlog.txt; \
13
+
fi \
14
+
fi \
15
+
done