AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
78 stars 6 forks source link

Add ability to list installed packages #34

Closed Slugger closed 4 years ago

Slugger commented 4 years ago

Is your feature request related to a problem? Please describe. I can upload a package via the emby api, but I can't list all installed packages. I would need to do this to determine if my package is installed before trying to upload it.

Describe the solution you'd like You have POST /ScripterX/Packages/Upload api call. We'd need a GET /ScripterX/Packages and maybe a GET /ScripterX/Packages/{PackageIdFromPackageInfo.json} to search for details about a specific package by id.

The basic idea here is my standalone app will include a package for ScripterX, I'd like to automate the installation/upgrade of that package everytime my app is started.

Describe alternatives you've considered The alternative is to always upload the package zip on startup. What happens if a package is uploaded that already exists?

AnthonyMusgrove commented 4 years ago

Too easy, so I've added two new API calls:

/Packages/Instances is what you'll be looking for with this request. You specify a package id (which is the id you give your package, which should stay the same throughout its lifetime), and it yields a LIST of PackageInfos (because a given packageId can have multiple installations):

http://localhost:8096/emby/ScripterX/Packages/Instances/scripterx.package.example?api_key=be9de3b352ca4761a4d6e3e77da32d1f

yields:

[ { "installationId": "8b91c4d0-66f2-47c8-9471-ae9c741d6b6f", "installationDirectory": "C:\\Users\\Anthony\\AppData\\Roaming\\Emby-Server\\programdata\\data/ScripterX/Packages/8b91c4d0-66f2-47c8-9471-ae9c741d6b6f", "installationName": "New installation of scripterx.package.example", "Id": "scripterx.package.example", "Name": "Example Package", "Author": "Anthony Musgrove", "Email": "anthony@emby-scripterx.info", "Version": "1.0.0" } ]

whereas http://localhost:8096/emby/ScripterX/Packages/Info/8b91c4d0-66f2-47c8-9471-ae9c741d6b6f?api_key=be9de3b352ca4761a4d6e3e77da32d1f

yields a SINGLE PackageInfo for a given installation ID:

{ "installationId": "8b91c4d0-66f2-47c8-9471-ae9c741d6b6f", "installationDirectory": "C:\\Users\\Anthony\\AppData\\Roaming\\Emby-Server\\programdata\\data/ScripterX/Packages/8b91c4d0-66f2-47c8-9471-ae9c741d6b6f", "installationName": "New installation of scripterx.package.example", "Id": "scripterx.package.example", "Name": "Example Package", "Author": "Anthony Musgrove", "Email": "anthony@emby-scripterx.info", "Version": "1.0.0" }

AnthonyMusgrove commented 4 years ago

Note however, for Version and Package Name to work, you'll need to reinstall your package on your Emby server atleast one more time (Because the installation process now extracts that information and adds it to your EmbyScripterX.xml plugin configuration), ie:

<InstalledPackages> <Package> <packageId>scripterx.package.example</packageId> <packageName>Example Package</packageName> <enabled>true</enabled> <installationId>8b91c4d0-66f2-47c8-9471-ae9c741d6b6f</installationId> <installationName>New installation of scripterx.package.example</installationName> <packageDescription>An example package for the ScripterX package system.</packageDescription> <installationDirectory>C:\Users\Anthony\AppData\Roaming\Emby-Server\programdata\data/ScripterX/Packages/8b91c4d0-66f2-47c8-9471-ae9c741d6b6f</installationDirectory> <packageAuthor>Anthony Musgrove</packageAuthor> <packageAuthorEmail>anthony@emby-scripterx.info</packageAuthorEmail> <packageVersion>1.0.0</packageVersion> </Package> </InstalledPackages>

AnthonyMusgrove commented 4 years ago

Now released on the Emby Catalog v3.0.4.2 :)

Slugger commented 4 years ago

Just tried this out and it's not working for me. I removed and reinstalled my package as per instructions. But any call I make to these endpoints returns a 404. I see the expected packageId and installationId in the EmbyScripterX.xml file and am using those same values in the api calls. No errors in the emby log pointing to any problems, just 404 anytime I call these endpoints.

Slugger commented 4 years ago

Cancel that, this is all good. Had the wrong test instance of Emby running. Fix confirmed.