Add asset folder or multiple assets to a change "HD Image/Video Player" setup

Hi,

is there a way to add multiple files or all files within a filder to a add asset “HD Image/Video Player” setup?
I need to create a setup with a few hundred images.

Regards
Kai

Not with the current UI. There will be an overhaul eventually to make such operations easier, but that’s not done yet.

Meanwhile the easiest way is probably to use the API. Here’s a Python program that does that:

#!/usr/bin/python
import requests, sys, os, json
from requests.auth import HTTPBasicAuth

API_KEY = os.environ['API_KEY']

def get_assets_with_prefix(prefix):
    r = requests.get(
        url = 'https://info-beamer.com/api/v1/asset/list',
        auth = HTTPBasicAuth('', API_KEY),
    )
    r.raise_for_status()
    assets = r.json()['assets']
    return [
        asset for asset in assets
        if asset['filename'].startswith(prefix)
    ]

def assign_folder(setup_id, folder):
    assets = get_assets_with_prefix(folder + '/')

    for asset in assets:
        print(asset['filename'])

    r = requests.post(
        url = 'https://info-beamer.com/api/v1/setup/%d' % setup_id,
        data = {
            'config': json.dumps({'': {
                'playlist': [{'file': asset['id']} for asset in assets],
            }}),
        },
        auth = HTTPBasicAuth('', API_KEY),
    )
    r.raise_for_status()

def main():
    assign_folder(int(sys.argv[1]), sys.argv[2])

if __name__ == "__main__":
    main()

Set the API_KEY environment variable to your api key, then run

python the_script.py 1234 videos

with 1234 being the id of your setup and videos being the “folder” name.

In case you’re wondering how the data parameter for the POST request is built: Have a look at the shape of the configuration for the hd player package. There’s the playlist named playlist where items are added. Assets are given as the file parameter (see line 87).

I just saw your other question. If you want to set all durations to 20 seconds, you’d have to modify the script as follows:

r = requests.post(
    url = 'https://info-beamer.com/api/v1/setup/%d' % setup_id,
    data = {
        'config': json.dumps({'': {
            'playlist': [{
                'file': asset['id'],
                'duration': 20, # this is new
            } for asset in assets],
        }}),
    },
    auth = HTTPBasicAuth('', API_KEY),
)

The duration is defined here.

Great thanks. That works for me. I wrote an Apple Script that updated the duration for me. But this surely the better way.