Command line to manage assets

Is there a command line tool to manage an asset to enable , disable, set play length etc?

I’d like to have a certain set of assets play during business hours, then a separate set of assets to play off business hours. I don’t think I can do that from the GUI, but if there’s a way, please let me know, otherwise if there’s a command line tool which I could use in a cron job that would be great. Right now I’m doing manually moving the asset files then rebooting, but it’s ugly.

Hi Luis,

It’s possible to manipulate the sqlite3 database directly, you can set the asset enabled field to 1 or 0 based on some aspect of the asset name (this requires a bit of scripting, but it’s quite doable)

basically: name the assets with “INOFFICE” and “OUTOFFICE” in the name, then select all the assets matching INOFFICE and when during office hours, set the enable bit to 1, and reverse for the OUTOFFICE. If you put all this in a script and run the script when you want to switch from cron, you’re in business :wink:

It’s probably best to do this only when necessary, otherwise you run the risk of the web ui trying to update the db when the script is running or vice versa… (should be handled by locking, but still)



@luisscreenly, it certainly is.

I wouldn’t recommend that you edit the sqlite database directly. That’s can cause all sort of issues. As @pooh22 correctly points out, this can cause issues concurrent writes, but also with corruption etc.

A far better approach is to use the API. The documentation can be found here. That’s the recommended way to do automated tasks and things that are not possible to do in the UI. You should be able to do this by simply sending a PATCH call to /api/v1.2/assets/{asset_id} and toggle the is_enabled flag.

Could you please give me an example of sending a patch call ?

Sure. I’d look something like this:

curl \ 
    --data '{"is_enabled": "0"}' \
    -X PATCH \

Where, a.b.c.d is the IP of the Raspberry Pi. Note that I haven’t tried this myself.

curl --data ‘{“is_enabled”: “0”}’ -X PATCH “

I tried the above from the pi running screenly and from a computer on the same network, and received “Access Denied”

I also tried passing -u pi:mypassword as params, no difference, and also tried port 8080 only because i see it’s listening on that,
Any help is greatly appreciated.

I’m not sure. Perhaps you’re running on and older version.

I just tried this against the OSE demo site, and it worked fine:

$ curl \
    -H "Content-Type: application/json" \
    --data '{"is_enabled": "0"}' \
    -X PATCH \
{"asset_id": "890fd859344944e891a57950d330d004", "mimetype": "webpage", "name": "", "end_date": "2020-11-18T18:30:00+00:00", "is_enabled": 0, "nocache": 0, "is_active": 0, "uri": "", "skip_asset_check": 0, "duration": "10", "play_order": 0, "start_date": "2020-10-19T17:30:00+00:00", "is_processing": 0}

Thank you Viktor,
Ok, this command you just showed me combined with the userid/pass works for me, if I leave out the userid/pass it doesn’t work. Here’s what I have in case it helps someone else.

curl -u admin:mypass -H “Content-Type: application/json” --data ‘{“is_enabled”: “0”}’ -X PATCH

(of course use your asset_id.)

Thanks @luisscreenly. Right! Yes, if you have authentication enabled, you need to pass on the credentials.