Skip to content

Commit

Permalink
Feat: complete implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jun 14, 2024
1 parent 09e4c1d commit c0266d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 9 additions & 6 deletions Jukebox/JukeboxBlissify.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- {"name": "JukeboxBlissify", "file": "Jukebox/JukeboxBlissify.lua", "version": 1, "desc": "Uses blissify-rs to populate the jukebox queue.", "order":1,"arguments":[]}
local blissify_path = "/usr/local/bin/blissify"
local blissify_path = mympd_env.var_blissify_path
local addSongs = 1
local min_jukebox_length = 50

Expand All @@ -10,6 +10,8 @@ local function send_error(message)
})
end

mympd.init()

-- Get length and last song of the jukebox queue
local rc, result = mympd.api("MYMPD_API_JUKEBOX_LIST", {
expression = "",
Expand Down Expand Up @@ -41,12 +43,13 @@ if last_song == nil then
end

-- Get songs from blissify
local full_song_path = mympd_state.music_directory .. "/" .. last_song
local prefix_len = #mympd_state.music_directory + 2
local songs = {}
-- TODO: specifiy dry-run - https://github.com/Polochon-street/blissify-rs/issues/60
local cmd = string.format("%s playlist %d 2>/dev/null", blissify_path, to_add)
local cmd = string.format("%s playlist --dry-run --from-song \"%s\" %d 2>/dev/null", blissify_path, full_song_path, to_add)
local output = mympd.os_capture(cmd)
for line in string.gmatch(output, "[^\n]+") do
table.insert(songs, line)
table.insert(songs, string.sub(line, prefix_len))
end

-- Add addSongs entries from playlist to the MPD queue
Expand All @@ -56,7 +59,7 @@ for i = 1, addSongs do
end
rc, result = mympd.api("MYMPD_API_QUEUE_APPEND_URIS", {
uris = addUris,
play = true
play = false
})
if rc == 1 then
send_error(result.message)
Expand All @@ -66,7 +69,7 @@ end
-- Add additional songs to the jukebox queue
addUris = {}
addSongs = addSongs + 1
for i = addSongs, songs.returnedEntities do
for i = addSongs, #songs do
table.insert(addUris, songs[i])
end
rc, result = mympd.api("MYMPD_API_JUKEBOX_APPEND_URIS", {
Expand Down
7 changes: 3 additions & 4 deletions Jukebox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ Adds random songs from a random playlist.

## Blissify

**Work in progress**

Blissify is a program used to make playlists of songs that sound alike from your MPD track library, à la Spotify radio.

This script creates a "seeded" playlist.

1. Install Blissify: https://github.com/Polochon-street/blissify-rs
2. Index your MPD library
3. Clear the queue and play a song from which Blissify should start.
2. Add a variable `blissify_path` to define the path to your blissify binary.
3. Index your MPD library: `blissify init` - this can take a long time.
4. Clear the queue and play a song from which Blissify should start.

0 comments on commit c0266d9

Please sign in to comment.