Closed AnthonyMusgrove closed 4 years ago
Can you provide some quick details on how I can create the package config interface? And also how I access those config options within my js? Thanks.
Hey mate, of course, this is the page I've put together so far: https://wiki.emby-scripterx.info/books/packages/page/getting-started
Almost done mate :)
Almost there!
Now saves to config xml :)
` var test_Setting_value = ScripterX.Config.Get("testSetting2").StringValue();
ScripterX.Log.Info("Value from config: " + test_Setting_value);
ScripterX.Config.Set("testSetting2", "Test 1 2 3");
var test_Setting_value2 = ScripterX.Config.Get("testSetting2").StringValue();
ScripterX.Log.Info("Value from config after setting: " + test_Setting_value2);
`
Yields:
2020-06-13 20:46:54.322 Info Emby ScripterX: 8b91c4d0-66f2-47c8-9471-ae9c741d6b6f: Value from config: Test 2 2020-06-13 20:46:54.323 Debug XmlSerializer: Serializing to file C:\Users\Anthony\AppData\Roaming\Emby-Server\programdata\data/ScripterX/Packages/8b91c4d0-66f2-47c8-9471-ae9c741d6b6f/PackageConfig.xml 2020-06-13 20:46:54.325 Info Emby ScripterX: 8b91c4d0-66f2-47c8-9471-ae9c741d6b6f: Value from config after setting: Test 1 2 3
https://wiki.emby-scripterx.info/books/packages/page/package-configuration
Just waiting for the Emby Team to fix the Plugin Portal so I can upload the new version to the catalog, however I've uploaded it here on github so you can manually copy it and use it until then.
:)
Now live on the catalog v3.0.4 :)
Is a ScripterX.Web
just a proxy to some class in .Net Core? If so, can you point me to the api docs for the interface? Basically, I'm looking for additional features: customize headers mainly, but also if there's anything else that might be available. Basically the web service I plan on posting to expects the content-type to be application/json. Just trying to figure out if this is possible.
Absolutely mate, at its essence, it is a proxy to an IHttpClient, I can expose all the functionality to truly customise it :) let me take a look right now.
And my apologies, I haven't yet documented but Web also has JsonPost,
ScripterX.Web.JsonPost(string url, string data)
which sets the content type as well to "application/json"
Currently, string data is just a JSON string, but I can add to this the ability to specify a JSON object, rather than JSON.stringify()'ing your json object first :)
How does this look for header customisation?
`var custom_headers = ScripterX.Web.CustomHeaderBuilder(); custom_headers.add("Content-Type", "application/json"); custom_headers.add("Accept", "application/json");
ScripterX.Web.JsonPost("http://192.168.1.10/hook.php", "test", custom_headers);`
2020-06-16 20:31:03.404 Debug Emby ScripterX: Custom Header Specified: Key=Content-Type, Value=application/json 2020-06-16 20:31:03.404 Debug Emby ScripterX: Custom Header Specified: Key=Accept, Value=application/json 2020-06-16 20:31:03.407 Info HttpClient: POST http://192.168.1.10/hook.php
I also fixed the Web.Get() to return the content received on Get;
var testget = ScripterX.Web.Get("http://192.168.1.10/");
ScripterX.Log.Debug("Get from Website: " + testget);
2020-06-16 21:06:58.089 Info HttpClient: GET http://192.168.1.10/ 2020-06-16 21:06:58.104 Debug Emby ScripterX: 8b91c4d0-66f2-47c8-9471-ae9c741d6b6f: Get from Website: <!DOCTYPE html> <html><head><title>MediusWeb</title></head> <body>MediusWeb, Welcome.</body> </html>
Get, JsonPost, Post all now support the custom headers parameter.
This is all good. Just having the JsonPost()
method is probably going to cover all of my needs, actually. I just can't stress enough how important the docs are going to be for this to be adopted by developers with some moderately complicated ideas/use cases.
Even here, had I known about JsonPost()
being available, I wouldn't have asked for the custom headers functionality. (Now with that said, custom headers is very useful anyways so definitely not a waste, but wouldn't have been a priority if I had known about JsonPost()
).
And then this new custom headers feature. I need to create a CustomHeaderBuilder
, populate that and then pass it as an arg. That's fine, but the docs need to have all of this info.
Very grateful for the additions, testing this JsonPost()
along with the context token map right now!
Looks like I have to pass the 3rd arg to JsonPost, even if I don't have any custom headers. An overloaded version of JsonPost() that only requires the first two args would be nice. Passing null as the 3rd arg causes a null pointer exception. I had to create an empty builder and pass it as 3rd arg.
I've fixed this one too mate, thank you. You no longer need to specify an empty CustomHeaderBuilder for it to function correctly. Omit this parameter and the requests will use default headers. :) (WIll be available for release tonight)
That's all done mate, up on Emby catalog now v3.0.4.4
Is your feature request related to a problem? Please describe. The Packages functionality requires a proper wiki and proper documentation for its functionality and usability.
Describe the solution you'd like A clear, concise wiki and documentation for Packages
@Slugger