Skip to content

Commit

Permalink
Merge branch 'main' of github.com:jcorporation/mympd-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Aug 4, 2024
2 parents 58767e3 + 626bb13 commit 54b727c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Tagart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ This script fetches tagart. You must create a directory in the `/var/lib/mympd/p
# Enable display of tags Artist and AlbumArtist
mkdir /var/lib/mympd/pics/Artist
mkdir /var/lib/mympd/pics/AlbumArtist
# Enable display of tags Composer
mkdir /var/lib/mympd/pics/Composer
```

## Usage

1. Create a new variable `fanart_tv_api_key` with your API key for Fanart.tv.
2. Import the `Tagart.lua` and the `TagartProviders.lua` scripts.
3. Create a new trigger
- Event: `mympd_albumart`
- Event: `mympd_tagart`
- Script: above script

## Available providers

| PROVIDER | SUPPORTED TAGS | REQUIRED TAGS |
| -------- | -------------- | ------------- |
| [Fanart.tv](https://fanart.tv/) | Artist, AlbumArtist | Artist, AlbumArtist, MUSICBRAINZ_ARTISTID |
| [Open Opus](https://openopus.org/) | Composer | Composer |
54 changes: 52 additions & 2 deletions Tagart/TagartProviders.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- {"name": "TagartProviders", "file": "Tagart/TagartProviders.lua", "version": 1, "desc": "Tagart providers for the Tagart script.", "order": 0, "arguments":[]}
-- {"name": "TagartProviders", "file": "Tagart/TagartProviders.lua", "version": 2, "desc": "Tagart providers for the Tagart script.", "order": 0, "arguments":[]}

local p_fanart_tv = {
name = "Fanart.tv",
Expand Down Expand Up @@ -54,8 +54,58 @@ local p_fanart_tv = {
end
}

local p_openopus = {
name = "Open Opus",
tags = {
Composer = true
},
get = function(tag, value, out)
local rc, code, header, body, song
rc, song = mympd.api("MYMPD_API_DATABASE_SEARCH", {
expression = "((" .. tag .. " == '" .. value .. "'))",
sort = "Title",
sortdesc = false,
offset = 0,
limit = 1,
fields = {
"composer"
}
})
if rc ~= 0 or
not song.data or
not song.data[1] or
not song.data[1].Composer or
song.data[1].Composer[1] == ""
then
mympd.log(7, "Composer not found")
return 1
end

local uri = "https://api.openopus.org/composer/list/search/" .. mympd.urlencode(song.data[1].Composer[1]) .. ".json"
rc, code, header, body = mympd.http_client("GET", uri, "", "")
if rc == 1 then
return 1
end
local data = json.decode(body)
if not data then
mympd.log(7, "Invalid json data received")
return 1
end
if not data.composers or
not data.composers[1] or
not data.composers[1].portrait
then
mympd.log(7, "Tagart not found")
return 1
end
return mympd.http_download(data.composers[1].portrait, "", out)

end
}

-- Return the providers as lua table
-- You can use this table to sort or disable providers
return {
p_fanart_tv
p_fanart_tv,
p_openopus
}
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Albumart/Albumart.lua":{"name":"Albumart","desc":"Fetches albumart on demand.","version":1},"Albumart/AlbumartProviders.lua":{"name":"AlbumartProviders","desc":"Albumart providers for the Albumart script.","version":1},"BatteryIndicator/BatteryIndicator.lua":{"name":"BatteryIndicator","desc":"Displays the battery status from sys filesystem.","version":1},"Channel/ChannelReadMessages.lua":{"name":"ChannelReadMessages","desc":"Reads all message from a MPD channel.","version":1},"Channel/ChannelSendMessage.lua":{"name":"ChannelSendMessage","desc":"Sends a message to a MPD channel.","version":2},"Channel/ChannelSubscribe.lua":{"name":"ChannelSubscribe","desc":"Subscribes to a MPD channel.","version":1},"Covercache/CovercachePrepopulate.lua":{"name":"CovercachePrepopulate","desc":"Prepopulates the myMPD covercache.","version":5},"Jukebox/JukeboxBlissify.lua":{"name":"JukeboxBlissify","desc":"Uses blissify-rs to populate the jukebox queue.","version":6},"Jukebox/JukeboxRandomPlaylist.lua":{"name":"JukeboxRandomPlaylist","desc":"Populates the jukebox queue with random songs from a random playlist.","version":2},"ListenBrainz/ListenBrainzFeedback.lua":{"name":"ListenBrainzFeedback","desc":"Sends feedback to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzPlayer.lua":{"name":"ListenBrainzPlayer","desc":"Sends the now playing info to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzPlaylistImport.lua":{"name":"ListenBrainzPlaylistImport","desc":"Imports generated playlists from ListenBrainz.","version":2},"ListenBrainz/ListenBrainzScrobbler.lua":{"name":"ListenBrainzScrobbler","desc":"Scrobbles songs to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzSetPin.lua":{"name":"ListenBrainzSetPin","desc":"Sets or unsets the pin on ListenBrainz.","version":1},"Lyrics/Lyrics.lua":{"name":"Lyrics","desc":"Fetches lyrics on demand.","version":4},"Lyrics/LyricsProviders.lua":{"name":"LyricsProviders","desc":"Lyrics providers for the Lyrics script.","version":3},"Maloja/MalojaScrobbler.lua":{"name":"MalojaScrobbler","desc":"Scrobbles songs to your Maloja server.","version":1},"Misc/EnableJukebox.lua":{"name":"EnableJukebox","desc":"Enables the jukebox with specified options.","version":1},"Misc/PlayRandomPlaylist.lua":{"name":"PlayRandomPlaylist","desc":"Plays a random playlist.","version":1},"Radiobrowser/Radiobrowser.lua":{"name":"Radiobrowser","desc":"Radiobrowser interface.","version":3},"Tagart/Tagart.lua":{"name":"Tagart","desc":"Fetches tagart on demand.","version":1},"Tagart/TagartProviders.lua":{"name":"TagartProviders","desc":"Tagart providers for the Tagart script.","version":1},"last.fm/lastfmFeedback.lua":{"name":"lastfmFeedback","desc":"Sends feedback to last.fm.","version":1},"last.fm/lastfmGetSessionKey.lua":{"name":"lastfmGetSessionKey","desc":"Fetches the session key from last.fm and sets the myMPD variable.","version":1},"last.fm/lastfmLib.lua":{"name":"lastfmLib","desc":"Library requried by the other last.fm modules.","version":1},"last.fm/lastfmPlayer.lua":{"name":"lastfmPlayer","desc":"Sends the now playing info to last.fm.","version":1},"last.fm/lastfmScrobbler.lua":{"name":"lastfmScrobbler","desc":"Scrobbles songs to last.fm.","version":1}}
{"Albumart/Albumart.lua":{"name":"Albumart","desc":"Fetches albumart on demand.","version":1},"Albumart/AlbumartProviders.lua":{"name":"AlbumartProviders","desc":"Albumart providers for the Albumart script.","version":1},"BatteryIndicator/BatteryIndicator.lua":{"name":"BatteryIndicator","desc":"Displays the battery status from sys filesystem.","version":1},"Channel/ChannelReadMessages.lua":{"name":"ChannelReadMessages","desc":"Reads all message from a MPD channel.","version":1},"Channel/ChannelSendMessage.lua":{"name":"ChannelSendMessage","desc":"Sends a message to a MPD channel.","version":2},"Channel/ChannelSubscribe.lua":{"name":"ChannelSubscribe","desc":"Subscribes to a MPD channel.","version":1},"Covercache/CovercachePrepopulate.lua":{"name":"CovercachePrepopulate","desc":"Prepopulates the myMPD covercache.","version":5},"Jukebox/JukeboxBlissify.lua":{"name":"JukeboxBlissify","desc":"Uses blissify-rs to populate the jukebox queue.","version":6},"Jukebox/JukeboxRandomPlaylist.lua":{"name":"JukeboxRandomPlaylist","desc":"Populates the jukebox queue with random songs from a random playlist.","version":2},"ListenBrainz/ListenBrainzFeedback.lua":{"name":"ListenBrainzFeedback","desc":"Sends feedback to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzPlayer.lua":{"name":"ListenBrainzPlayer","desc":"Sends the now playing info to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzPlaylistImport.lua":{"name":"ListenBrainzPlaylistImport","desc":"Imports generated playlists from ListenBrainz.","version":2},"ListenBrainz/ListenBrainzScrobbler.lua":{"name":"ListenBrainzScrobbler","desc":"Scrobbles songs to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzSetPin.lua":{"name":"ListenBrainzSetPin","desc":"Sets or unsets the pin on ListenBrainz.","version":1},"Lyrics/Lyrics.lua":{"name":"Lyrics","desc":"Fetches lyrics on demand.","version":4},"Lyrics/LyricsProviders.lua":{"name":"LyricsProviders","desc":"Lyrics providers for the Lyrics script.","version":3},"Maloja/MalojaScrobbler.lua":{"name":"MalojaScrobbler","desc":"Scrobbles songs to your Maloja server.","version":1},"Misc/EnableJukebox.lua":{"name":"EnableJukebox","desc":"Enables the jukebox with specified options.","version":1},"Misc/PlayRandomPlaylist.lua":{"name":"PlayRandomPlaylist","desc":"Plays a random playlist.","version":1},"Radiobrowser/Radiobrowser.lua":{"name":"Radiobrowser","desc":"Radiobrowser interface.","version":3},"Tagart/Tagart.lua":{"name":"Tagart","desc":"Fetches tagart on demand.","version":1},"Tagart/TagartProviders.lua":{"name":"TagartProviders","desc":"Tagart providers for the Tagart script.","version":2},"last.fm/lastfmFeedback.lua":{"name":"lastfmFeedback","desc":"Sends feedback to last.fm.","version":1},"last.fm/lastfmGetSessionKey.lua":{"name":"lastfmGetSessionKey","desc":"Fetches the session key from last.fm and sets the myMPD variable.","version":1},"last.fm/lastfmLib.lua":{"name":"lastfmLib","desc":"Library requried by the other last.fm modules.","version":1},"last.fm/lastfmPlayer.lua":{"name":"lastfmPlayer","desc":"Sends the now playing info to last.fm.","version":1},"last.fm/lastfmScrobbler.lua":{"name":"lastfmScrobbler","desc":"Scrobbles songs to last.fm.","version":1}}

0 comments on commit 54b727c

Please sign in to comment.