Skip to content

Scripting

Pk11 edited this page Jun 17, 2022 · 3 revisions

dsidl supports simplistic scripts to download multiple files by creating your QR with JSON data. Either JSON arrays or objects are supported, with arrays simply being a list of URLs that it prompts the user for location/name like normal and objects allowing you to set both the URL and the output path.

Examples

[
    "It'll print anything that doesn't start 'http'",
    "https://example.com",
    "http://uwu.xn--rck9c.xn--tckwe",
    "Thanks for downloading!"
]

Example QR of the above JSON

{
    "sd:/example.html": "https://example.com",
    "": "Comments still work",
    "sd:/uwu.html": "http://uwu.xn--rck9c.xn--tckwe"
}

Example QR of the above JSON

External scripts

You can also make an external script that is simply referenced by the QR code. This can be useful if you want to be able to change the script with the same QR or if your script is too large to fit in a QR code.

To start the script you must create a QR like the following:

{
    "dsidl:src": "https://gist.githubusercontent.com/Epicpkmn11/ac5100d1d78897198e6d23957bbad2b1/raw/3e02ad0cdf8d04002fd988f6b7f8d19a2b8c07ca/example.json"
}

Example QR of the above JSON

Then the file pointed to must have the following structure:

{
    "dsidl": 1,
    "script": []
}

The value of "script" can be any script as described above. "dsidl" must be 1, this is used to check that it's a supported script.

Advanced

Instead of strings it's also possible to use an object which allows additional download options. Currently supported are:

{
    "url": "https://example.com",
    "msg": "This is an example, it will skip the download if the file already exists.",
    "overwrite": false
}
  • url - The same as providing a string normally
  • msg - An additional message to print out, the same as a non-URL string normally
  • overwrite - A boolean that when false will make the file be skipped if it already exists
    • Only compatible with object type scripts as the absolute file path must be specified
Clone this wiki locally