-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharts-collage.lua
68 lines (59 loc) · 2.67 KB
/
arts-collage.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-----------------------------------------------------
-- ----------------------------------------------- --
-- ▄ ▄ ▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄ ▄ --
-- ▐░▌ ▐░▌ ▐░▌▐░█▀▀▀▀▀ ▀▀█░█▀▀ ▐░▌ ▐░▌ --
-- ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░█ █░▌ --
-- ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░░░░░░░▌ --
-- ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▀▀▀▀▀█░▌ --
-- ▐░█▄▄▄▄▄ ▐░█▄▄▄█░▌▐░█▄▄▄▄▄ ▄▄█░█▄▄ ▐░▌ --
-- ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀ --
-- ----------------------------------------------- --
-- ----- Script to print a collage of album ------ --
-- ----- from Ampache. --------------------------- --
-- -------- https://github.com/icefields --------- --
-----------------------------------------------------
local tile_images = require("tile_images")
local handshake = require("ampache-handshake")
local print_arts = require("print-arts")
local function contains(array, element)
for _, value in ipairs(array) do
if value == element then
return true
end
end
return false
end
local helpMessage = "Usage: lua arts-collage.lua [-s | -h | -f] <server.url> <username> <password>"
-- Check the number of command-line arguments
if #arg < 3 then
error(helpMessage)
end
local validOptions = {
["-s"] = 16,
["-f"] = "recent",
["-h"] = false,
["--help"] = false
}
local isAnyOption = false
local values = {}
local argsToIgnore = {}
for i, currArg in ipairs(arg) do
if currArg:sub(1, 2) == "-s" and validOptions[ currArg:sub(1, 2) ] ~= nil then
validOptions[currArg] = arg[i+1]
table.insert(argsToIgnore, i+1)
isAnyOption = true
elseif currArg:sub(1, 2) == "-f" then
validOptions[currArg] = arg[i+1]
table.insert(argsToIgnore, i+1)
isAnyOption = true
elseif not contains(argsToIgnore, i) then
table.insert(values, currArg)
end
end
local server_url = values[1]
local username = values[2]
local password = values[3]
local authToken = handshake.getAuthToken(server_url, username, password)
local reqUrl = server_url.."/server/json.server.php?action=stats&type=album&limit="..validOptions["-s"].."&filter="..validOptions["-f"].."&exact=1&offset=0&hide_search=0&show_dupes=1&auth="..authToken.."&username="..username
local artList = print_arts.artUrls(reqUrl, false)
tile_images.tileImages(artList, true)