Skip to content

Commit 74df472

Browse files
committed
Add role for using Spotify soloist
Unlike librespot this supports lossless. Unfortunately it also requires re-install every 90 days which this roles handles
1 parent c94bf69 commit 74df472

5 files changed

Lines changed: 95 additions & 0 deletions

File tree

‎roles/spotify_soloist/tasks/main.yml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
register: spotify_soloist_arch
55
changed_when: false
66
check_mode: false
7+
tags: argh
8+
9+
- name: Check if Spotify arch is compatible
10+
ansible.builtin.fail:
11+
msg: Seems no binary for your Architecture is available from Spotify
12+
when: spotify_soloist_arch.stdout not in spotify_soloist_supported_arches
13+
tags: argh
714

815
- name: Fetch Spotify soloist
916
ansible.builtin.get_url:
@@ -17,6 +24,7 @@
1724
ansible.builtin.unarchive:
1825
src: /usr/local/bin/spotify_soloist.tar.gz
1926
dest: /usr/local/bin/
27+
include: soloist
2028
remote_src: true
2129
when: not ansible_check_mode
2230

@@ -46,3 +54,48 @@
4654
enabled: true
4755
scope: user
4856
when: not ansible_check_mode
57+
58+
- name: Template Spotify soloist download service
59+
ansible.builtin.template:
60+
src: spotify_soloist_reinstall.service.j2
61+
dest: /etc/systemd/system/spotify_soloist_reinstall.service
62+
owner: media
63+
group: media
64+
mode: '600'
65+
when: not ansible_check_mode
66+
tags: create_soloist_service
67+
68+
- name: Template Spotify soloist download restart script
69+
ansible.builtin.template:
70+
src: templates/soloist_refresh.sh.j2
71+
dest: /usr/local/bin/soloist_refresh.sh
72+
owner: root
73+
group: root
74+
mode: '700'
75+
when: not ansible_check_mode
76+
notify: Reload systemd
77+
tags: argh
78+
79+
- name: Template Spotify soloist download timer and service
80+
ansible.builtin.template:
81+
src: "templates/{{ item }}"
82+
dest: /etc/systemd/system/{{ item|regex_replace(".j2","") }}
83+
owner: root
84+
group: root
85+
mode: '600'
86+
when: not ansible_check_mode
87+
notify: Reload systemd
88+
loop:
89+
- "spotify_soloist_reinstall.timer.j2"
90+
- "spotify_soloist_reinstall.service.j2"
91+
tags: argh
92+
93+
- name: Enable Schedule soloist download timer
94+
become: true
95+
ansible.builtin.systemd:
96+
name: spotify_soloist_reinstall.timer
97+
state: started
98+
enabled: true
99+
when: not ansible_check_mode
100+
tags: argh
101+
notify: Reload systemd
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
/usr/bin/curl --location \
5+
--output-dir /tmp/ \
6+
--silent \
7+
--no-buffer \
8+
--remote-name {{ spotify_soloist_download_url }}{{ spotify_soloist_arch.stdout }}.tar.gz
9+
10+
/usr/bin/tar -C /usr/local/bin/ \
11+
-xzvf \
12+
/tmp/soloist_release_{{ spotify_soloist_arch.stdout }}.tar.gz \
13+
--get soloist
14+
15+
/usr/bin/systemctl --user -M media@ restart spotify_soloist
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Unit]
2+
Description=Download and replace and restart spotify soloist binary
3+
4+
[Service]
5+
Type=oneshot
6+
7+
ExecStart=/usr/local/bin/soloist_refresh.sh
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=trigger soloist re-downloda and re-start
3+
4+
[Timer]
5+
6+
# Run monthly with some flex
7+
OnCalendar=Mon *-*-01..07 10:00:00
8+
AcuracySec=7
9+
Persistent=true
10+
11+
[Install]
12+
WantedBy=timers.target
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
3+
spotify_soloist_download_url: "https://soloist-builds.spotifycdn.com/soloist_release_"
4+
5+
spotify_soloist_supported_arches:
6+
- arm64
7+
- arm32
8+
- x86

0 commit comments

Comments
 (0)