Skip to content

Commit

Permalink
Upd: improve index format
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jun 11, 2024
1 parent af45047 commit e5d5ab4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 165 deletions.
152 changes: 1 addition & 151 deletions index.json
Original file line number Diff line number Diff line change
@@ -1,151 +1 @@
{"scripts":[{
"file": "Albumart/Albumart.lua",
"name": "Albumart",
"desc": "Fetches albumart on demand.",
"version": 1
}
,{
"file": "Albumart/AlbumartProviders.lua",
"name": "AlbumartProviders",
"desc": "Albumart providers for the Albumart script.",
"version": 1
}
,{
"file": "BatteryIndicator/BatteryIndicator.lua",
"name": "BatteryIndicator",
"desc": "Displays the battery status from sys filesystem.",
"version": 1
}
,{
"file": "Channel/ChannelReadMessages.lua",
"name": "ChannelReadMessages",
"desc": "Reads all message from a MPD channel.",
"version": 1
}
,{
"file": "Channel/ChannelSendMessage.lua",
"name": "ChannelSendMessage",
"desc": "Sends a message to a MPD channel.",
"version": 1
}
,{
"file": "Channel/ChannelSubscribe.lua",
"name": "ChannelSubscribe",
"desc": "Subscribes to a MPD channel.",
"version": 1
}
,{
"file": "Covercache/CovercachePrepopulate.lua",
"name": "CovercachePrepopulate",
"desc": "Prepopulates the myMPD covercache.",
"version": 1
}
,{
"file": "Jukebox/JukeboxRandomPlaylist.lua",
"name": "JukeboxRandomPlaylist",
"desc": "Populates the jukebox queue with random songs from a random playlist.",
"version": 1
}
,{
"file": "ListenBrainz/ListenBrainzFeedback.lua",
"name": "ListenBrainzFeedback",
"desc": "Sends feedback to ListenBrainz.",
"version": 1
}
,{
"file": "ListenBrainz/ListenBrainzPlaylistImport.lua",
"name": "ListenBrainzPlaylistImport",
"desc": "Imports generated playlists from ListenBrainz.",
"version": 1
}
,{
"file": "ListenBrainz/ListenBrainzScrobbler.lua",
"name": "ListenBrainzScrobbler",
"desc": "Scrobbles songs to ListenBrainz.",
"version": 1
}
,{
"file": "ListenBrainz/ListenBrainzSetPin.lua",
"name": "ListenBrainzSetPin",
"desc": "Sets or unsets the pin on ListenBrainz.",
"version": 1
}
,{
"file": "Lyrics/Lyrics.lua",
"name": "Lyrics",
"desc": "Fetches lyrics on demand.",
"version": 3
}
,{
"file": "Lyrics/LyricsProviders.lua",
"name": "LyricsProviders",
"desc": "Lyrics providers for the Lyrics script.",
"version": 3
}
,{
"file": "Maloja/MalojaScrobbler.lua",
"name": "MalojaScrobbler",
"desc": "Scrobbles songs to your Maloja server.",
"version": 1
}
,{
"file": "Misc/EnableJukebox.lua",
"name": "EnableJukebox",
"desc": "Enables the jukebox with specified options.",
"version": 1
}
,{
"file": "Misc/PlayRandomPlaylist.lua",
"name": "PlayRandomPlaylist",
"desc": "Plays a random playlist.",
"version": 1
}
,{
"file": "Tagart/Tagart.lua",
"name": "Tagart",
"desc": "Fetches tagart on demand.",
"version": 1
}
,{
"file": "Tagart/TagartProviders.lua",
"name": "TagartProviders",
"desc": "Tagart providers for the Tagart script.",
"version": 1
}
,{
"file": "last.fm/lastfmFeedback.lua",
"name": "lastfmFeedback",
"desc": "Sends feedback to last.fm.",
"version": 1
}
,{
"file": "last.fm/lastfmGetSessionKey.lua",
"name": "lastfmGetSessionKey",
"desc": "Fetches the session key from last.fm and sets the myMPD variable.",
"version": 1
}
,{
"file": "last.fm/lastfmLib.lua",
"name": "lastfmLib",
"desc": "Library requried by the other last.fm modules.",
"version": 1
}
,{
"file": "last.fm/lastfmPlayer.lua",
"name": "lastfmPlayer",
"desc": "Sends the now playing info to last.fm.",
"version": 1
}
,{
"file": "last.fm/lastfmScrobbler.lua",
"name": "lastfmScrobbler",
"desc": "Scrobbles songs to last.fm.",
"version": 1
}
,{
"file": "yt-dlp/yt-dlp.lua",
"name": "yt-dlp",
"desc": "Streams songs and playlists with the help of yt-dlp.",
"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":1},"Channel/ChannelSubscribe.lua":{"name":"ChannelSubscribe","desc":"Subscribes to a MPD channel.","version":1},"Covercache/CovercachePrepopulate.lua":{"name":"CovercachePrepopulate","desc":"Prepopulates the myMPD covercache.","version":1},"Jukebox/JukeboxRandomPlaylist.lua":{"name":"JukeboxRandomPlaylist","desc":"Populates the jukebox queue with random songs from a random playlist.","version":1},"ListenBrainz/ListenBrainzFeedback.lua":{"name":"ListenBrainzFeedback","desc":"Sends feedback to ListenBrainz.","version":1},"ListenBrainz/ListenBrainzPlaylistImport.lua":{"name":"ListenBrainzPlaylistImport","desc":"Imports generated playlists from ListenBrainz.","version":1},"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":3},"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},"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},"yt-dlp/yt-dlp.lua":{"name":"yt-dlp","desc":"Streams songs and playlists with the help of yt-dlp.","version":1}}
20 changes: 6 additions & 14 deletions index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,22 @@ set -u
# Create index of lua scripts
rm -f "index.json"
exec 3<> "index.json"
printf "{\"scripts\":[" >&3
printf "{" >&3
I=0
for F in */*.lua
do
[ "$I" -gt 0 ] && printf "," >&3
NAME=$(basename "$F" .lua)
NAME=$(basename "$F" .lua | jq -Ra .)
FILE=$(printf "%s" "$F" | jq -Ra .)
SCRIPT_HEADER=$(head -1 "$F" < $F | sed 's/^-- //')
DESC=$(printf "%s" "$SCRIPT_HEADER" | jq -r '.desc')
DESC=$(printf "%s" "$SCRIPT_HEADER" | jq -r '.desc' | jq -Ra .)
VERSION=$(printf "%s" "$SCRIPT_HEADER" | jq -r '.version')
[ "$DESC" = "null" ] && DESC=""
[ "$VERSION" = "null" ] && VERSION="0"
jq -n --arg file "$F" \
--arg name "$NAME" \
--arg desc "$DESC" \
--argjson version "$VERSION" \
'{
"file": $file,
"name": $name,
"desc": $desc,
"version": $version
}' >&3
printf '%s:{"name":%s,"desc":%s,"version":%s}' "$FILE" "$NAME" "$DESC" "$VERSION">&3
I=$((I+1))
done
printf "]}\n" >&3
printf "}\n" >&3
exec 3>&-

jq "." < index.json > /dev/null

0 comments on commit e5d5ab4

Please sign in to comment.