Last active
January 17, 2023 22:53
-
-
Save gdyr/73d8931c213239fdb5d38b1ef68b0afa to your computer and use it in GitHub Desktop.
List playlists on Q-Sys using Lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- First we find all the files in the "playlist" directory | |
PlaylistFiles = dir.get('media/Playlists/') | |
-- Next we make a table that's going to contain all our playlist names | |
PlaylistNames = {} | |
-- Next we go through the list of playlist files we've found | |
for _,f in ipairs(PlaylistFiles) do | |
-- Open the file | |
local playlistFilename = f.name | |
local file = io.open('media/Playlists/' .. f.name) | |
-- [[ Search through the file for a new playlist name ]] | |
-- Declare a function our for loop can call repeatedly to get new lines | |
local read = function() return file:read('*line'); end | |
-- Go through the lines in the file | |
for line in read do | |
-- Try and find a playlist name declaration in the line | |
local name = line:match('^#QPL NAME ([^\r\n]*)') | |
-- If we found one, add it to our list, | |
-- and skip reading the rest of the lines | |
if(name) then | |
table.insert(PlaylistNames, name) | |
break | |
end | |
end | |
-- Close the file | |
file:close() | |
end | |
-- Assign these names as choices on the drop-down box | |
Controls.Playlists.Choices = PlaylistNames |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment