-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimilar.lua
More file actions
67 lines (57 loc) · 2.74 KB
/
similar.lua
File metadata and controls
67 lines (57 loc) · 2.74 KB
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
-----------------------------------------------------
-- ----------------------------------------------- --
-- ▄ ▄ ▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄ ▄ --
-- ▐░▌ ▐░▌ ▐░▌▐░█▀▀▀▀▀ ▀▀█░█▀▀ ▐░▌ ▐░▌ --
-- ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░█ █░▌ --
-- ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░░░░░░░▌ --
-- ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▀▀▀▀▀█░▌ --
-- ▐░█▄▄▄▄▄ ▐░█▄▄▄█░▌▐░█▄▄▄▄▄ ▄▄█░█▄▄ ▐░▌ --
-- ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀ --
-- ----------------------------------------------- --
-- ------- Luci4 util print Ampache albums ------- --
-- -------- https://github.com/icefields --------- --
-----------------------------------------------------
-- setting the local path so the script can find dependencies
local script_path = debug.getinfo(1, "S").source:match("(.*/)") or ""
script_path = script_path:sub(2) -- Removes the '@' at the beginning if it exists
local script_dir = script_path:match("(.+)/") -- Get everything before the last '/'
script_dir = script_dir or "" -- If no directory, make it an empty string
package.path = script_dir .. "/?.lua;" .. package.path
local ampache = require("ampache-common")
local ampacheHttp = require("ampache-http")
if (ampache.shouldPrintHelp()) then
ampache.printHelp("similar.lua")
return
end
local server_url, username, password, limit, filter_value, is_json_output, isPrintUrl, include, typeValue =
ampache.parseArgs(arg)
local res, code, response_headers, status, json_response, data =
ampacheHttp.makeRequest({
serverUrl = server_url,
action = "get_similar",
type = typeValue,
username = username,
password = password,
limit = limit,
filterValue = filter_value
})
if code == 200 then
-- if the -j option is passed, just print the json file
if is_json_output == true then
print(json_response)
return
end
for _, item in ipairs(data["album"]) do
ampache.safePrint(item.artist.name .. " -", item.name)
ampache.safePrint("id:", item.id)
ampache.safePrint("Time:", item.time)
ampache.safePrint("Year:", item.year)
ampache.safePrint("Songcount:", item.songcount)
if item.art and item.has_art then
ampache.safePrint("Art:", item.art)
end
print("\n") -- Add a blank line between items
end
else
print("HTTP request failed with status: " .. status)
end