File debug/contrib/lualibs/mympd.lua

Functions

mympd.api (method, params) Calls the myMPD jsonrpc api
mympd.covercache_write (src, uri) Write a file for the covercache
mympd.hash_sha1 (string) Returns the SHA1 hash of string.
mympd.hash_sha256 (string) Returns the SHA256 hash of string.
mympd.http_client (method, uri, headers, payload) Simple HTTP client
mympd.http_download (uri, out) Download a file over http
mympd.http_redirect (location) Sends a HTTP temporary redirect (302).
mympd.http_reply (status, header, body) Sends a HTTP reply.
mympd.init () Populate the global mympd_state lua table
mympd.log (loglevel, message) Logs to the myMPD log.
mympd.notify_client (severity, message) Sends a notification to the client that started this script.
mympd.notify_partition (severity, message) Sends a notification to all clients in the current partition.
mympd.os_capture (cmd) Execute a system command and capture its output
mympd.urldecode (string, form) URL decoding
mympd.urlencode (string) URL encoding


Functions

mympd.api (method, params)
Calls the myMPD jsonrpc api

Parameters

  • method:
  • params:

Return values:

  1. rc 0 for success, else 1
  2. result jsonrpc result
mympd.covercache_write (src, uri)
Write a file for the covercache

Parameters

  • src: File to rename
  • uri: URI to create the covercache file for
mympd.hash_sha1 (string)
Returns the SHA1 hash of string.

Parameters

  • string: String to hash

Return value:

SHA1 hash of string
mympd.hash_sha256 (string)
Returns the SHA256 hash of string.

Parameters

  • string: String to hash

Return value:

SHA256 hash of string
mympd.http_client (method, uri, headers, payload)
Simple HTTP client

Parameters

  • method: HTTP method, only GET or POST is supported
  • uri: The uri to access
  • headers: Additional headers terminated by "\r\n"
  • payload: Payload to send (POST only)

Return values:

  1. rc 0 for success, else 1
  2. code HTTP status code
  3. header HTTP Headers
  4. body HTTP Body
mympd.http_download (uri, out)
Download a file over http

Parameters

  • uri: The uri to access
  • out: Filename to write the response body

Return value:

rc 0 for success, else 1
mympd.http_redirect (location)
Sends a HTTP temporary redirect (302). Can be only used in the "http" event

Parameters

  • location: Location to redirect
mympd.http_reply (status, header, body)
Sends a HTTP reply. Can be only used in the "http" event

Parameters

  • status: HTTP status code
  • header: Additional headers terminated by "\r\n"
  • body: HTTP Body to send
mympd.init ()
Populate the global mympd_state lua table
mympd.log (loglevel, message)
Logs to the myMPD log.

Parameters

  • loglevel: Syslog loglevel 0 = Emergency 1 = Alert 2 = Critical 3 = Error 4 = Warning 5 = Notice 6 = Info 7 = Debug
  • message:
mympd.notify_client (severity, message)
Sends a notification to the client that started this script.

Parameters

  • severity: Severity 0 = Info 1 = Warning 2 = Error
  • message: Jsonrpc message to send
mympd.notify_partition (severity, message)
Sends a notification to all clients in the current partition.

Parameters

  • severity: Severity 0 = Info 1 = Warning 2 = Error
  • message: Jsonrpc message to send
mympd.os_capture (cmd)
Execute a system command and capture its output

Parameters

  • cmd: Command to execute

Return value:

Captured output of cmd
mympd.urldecode (string, form)
URL decoding

Parameters

  • string: String to URL decode
  • form: true = decode a url form encoded string

Return value:

Decoded string
mympd.urlencode (string)
URL encoding

Parameters

  • string: String to URL encode

Return value:

Encoded string

Valid XHTML 1.0!