Skip to content

Commit 76fe9b4

Browse files
feat: added support for renaming the default Spotify device name (#53)
Co-authored-by: Max Isom <[email protected]>
1 parent a5c1503 commit 76fe9b4

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ services:
4545
- SPOTIFY_PASSWORD=
4646
- DISCORD_USER_ID= # Discord user ID of the user you want Aoede to follow
4747
- SPOTIFY_BOT_AUTOPLAY= # Autoplay similar songs when your music ends (true/false)
48+
- SPOTIFY_DEVICE_NAME=
4849
```
4950
5051
### Docker:
@@ -55,6 +56,7 @@ SPOTIFY_USERNAME=
5556
SPOTIFY_PASSWORD=
5657
DISCORD_USER_ID=
5758
SPOTIFY_BOT_AUTOPLAY=
59+
SPOTIFY_DEVICE_NAME=
5860
```
5961

6062
```bash

config.sample.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ DISCORD_TOKEN="the discord bot token"
22
SPOTIFY_USERNAME="your spotify email"
33
SPOTIFY_PASSWORD="your spotify password"
44
DISCORD_USER_ID="your discord id here"
5-
SPOTIFY_BOT_AUTOPLAY=true
5+
SPOTIFY_BOT_AUTOPLAY=true
6+
SPOTIFY_DEVICE_NAME="custom device name in spotify, optional"

src/lib/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ pub struct Config {
1616
pub discord_user_id: u64,
1717
#[serde(alias = "SPOTIFY_BOT_AUTOPLAY")]
1818
pub spotify_bot_autoplay: bool,
19+
#[serde(alias = "SPOTIFY_DEVICE_NAME")]
20+
#[serde(default = "default_spotify_device_name")]
21+
pub spotify_device_name: String,
22+
}
23+
24+
fn default_spotify_device_name() -> String {
25+
"Aoede".to_string()
1926
}
2027

2128
impl Config {

src/lib/player.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct SpotifyPlayer {
3838
pub event_channel: Option<Arc<tokio::sync::Mutex<PlayerEventChannel>>>,
3939
mixer: Box<SoftMixer>,
4040
pub bot_autoplay: bool,
41+
pub device_name: String,
4142
}
4243

4344
pub struct EmittedSink {
@@ -208,6 +209,7 @@ impl SpotifyPlayer {
208209
quality: Bitrate,
209210
cache_dir: Option<String>,
210211
bot_autoplay: bool,
212+
device_name: String,
211213
) -> SpotifyPlayer {
212214
let credentials = Credentials::with_password(username, password);
213215

@@ -259,12 +261,13 @@ impl SpotifyPlayer {
259261
event_channel: Some(Arc::new(tokio::sync::Mutex::new(rx))),
260262
mixer,
261263
bot_autoplay,
264+
device_name,
262265
}
263266
}
264267

265268
pub async fn enable_connect(&mut self) {
266269
let config = ConnectConfig {
267-
name: "Aoede".to_string(),
270+
name: self.device_name.clone(),
268271
device_type: DeviceType::AudioDongle,
269272
initial_volume: None,
270273
has_volume_ctrl: true,

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ async fn main() {
305305
Bitrate::Bitrate320,
306306
cache_dir,
307307
config.spotify_bot_autoplay,
308+
config.spotify_device_name.clone(),
308309
)
309310
.await,
310311
));

0 commit comments

Comments
 (0)