Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Custom JSON API calls #263

Open
diabl0w opened this issue Dec 16, 2019 · 6 comments
Open

[REQUEST] Custom JSON API calls #263

diabl0w opened this issue Dec 16, 2019 · 6 comments

Comments

@diabl0w
Copy link

diabl0w commented Dec 16, 2019

It would be cool to be able to define custom JSON API calls (https://kodi.wiki/view/JSON-RPC_API) in the broker config file.

PS sorry for opening so many feature requests at once.... This program is fantastic as is, and I appreciate your development!

@keydon
Copy link
Collaborator

keydon commented Dec 16, 2019

basically you can do that, even though it would not all be contained in the broker-file and the solution would not be configuration only. But since you seem capabale: you would have to implement that custom business operation yourself and reference that in the broker-file.

Alternative: Call the Kodi-API from IFTTT directly. But the "One-IFTTT-App to rule them all" goes down the drain.

@diabl0w
Copy link
Author

diabl0w commented Dec 16, 2019

basically you can do that, even though it would not all be contained in the broker-file and the solution would not be configuration only. But since you seem capabale: you would have to implement that custom business operation yourself and reference that in the broker-file.

Alternative: Call the Kodi-API from IFTTT directly. But the "One-IFTTT-App to rule them all" goes down the drain.

Great! thanks for all your replies. I'll have to dig around the code to see if I can figure it out. Im not a programmer, im just a hobbyist but I have gotten pretty good of at least learning to read and understand code and modify it a little. I like to self-host things as much as possible as well so the one-iftt-app to rule them all is the preferred method :)

@diabl0w
Copy link
Author

diabl0w commented Dec 17, 2019

for anyone curious or wanting to help, i was trying to add the functionality of communicating with the great openmeta/openinfo addons. I was able to achieve a global search function of openinfo so that i can just ask google to search for any movie/tvshow and I would be able to get it. For example "Ok Google, Living room TV search for 'The Irishman'". I was successfully able to do this, although it is a bit hacky and it is almost definitely not the proper code but it does work. In helpers.js I added:

exports.kodiSearchOpenInfo = (request, response) => { 
    let searchString = request.query.q.trim();
    let Kodi = request.kodi
    const params = {
        addonid: 'script.extendedinfo',
        params: {
            'info': 'search_menu'
        }
    };
    return Kodi.Addons.ExecuteAddon(params)
    .then(() => sleep(e))
    .then(() => Kodi.Input.SendText({"text": searchString, "done": true}));
};

Some issues are:

  1. I have no idea the difference between using "exports." or just "const"
  2. There is probably a better way to run the actions besides using ".then()"
  3. The sleep function is definitely hacky, it would be better if we can query the current window and wait until it is a Virtual Keyboard
  4. Even better is if we can just pass the searchstring straight to extendedinfo (OpenInfo) in the params, but I could not find any examples of someone else doing that so since I am not a programmer I am not sure how to do that. (I am a copy/paster from other's examples)

@keydon
Copy link
Collaborator

keydon commented Jan 5, 2020

  1. not sure either. I treet it as public vs. private xD
  2. thats fine since its consistent with the other functions. the 'new' kid on the block would be async/ await.
  3. The kodi api is very limited when it comes to interacting with the UI. So hacky is the best we can do^^
  4. Addons usually have an internal URL like plugin://... (i.e. see the implementation of kodiSearchYoutube) You can try to find that URL for your addon by either looking through the addons code or like I have done with the youtube addon: enable debug logging in kodi, execute the action you want to support, check the logs for the internal URL. This of course only works if the developer of the addon logs stuff^^

@diabl0w
Copy link
Author

diabl0w commented Jan 5, 2020

  1. not sure either. I treet it as public vs. private xD
  2. thats fine since its consistent with the other functions. the 'new' kid on the block would be async/ await.
  3. The kodi api is very limited when it comes to interacting with the UI. So hacky is the best we can do^^
  4. Addons usually have an internal URL like plugin://... (i.e. see the implementation of kodiSearchYoutube) You can try to find that URL for your addon by either looking through the addons code or like I have done with the youtube addon: enable debug logging in kodi, execute the action you want to support, check the logs for the internal URL. This of course only works if the developer of the addon logs stuff^^

Thanks for all your help! I am trying to solve point number 4, as that would also eliminate point numbers 2 and 3 as well.

@keydon
Copy link
Collaborator

keydon commented Jun 20, 2020

I just saw your other ticket at that 3rd-party addon.
Kodi has an API to send keyword input (Kodi.Input.SendText). So if you found the URL, that opens the search-dialog, you could try to sleep for a second (so the UI can catch up) and then send the search-keyword, followed by Kodi.Input.Select for pressing "Enter".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants