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

Feature Request - list_launch_points #69

Open
mrDuplo opened this issue Dec 2, 2021 · 8 comments
Open

Feature Request - list_launch_points #69

mrDuplo opened this issue Dec 2, 2021 · 8 comments

Comments

@mrDuplo
Copy link

mrDuplo commented Dec 2, 2021

Hi,

I've tried to extend the ApplicationControl to get "ssap://com.webos.applicationManager/listLaunchPoints".
Should be similar to 'list_apps()'. No success for me so far.

This array should contain URIs to usable icons for my app.

Anybody else been able to retrieve this information?

@supersaiyanmode
Copy link
Owner

Hi there! I have a few questions:

  1. Can you please create a PR, or point me to your fork? I'd just like to confirm a few things about how you extended it.
  2. What do you mean by icons? IIRC the icons are already present in the resultant object that is returned by list_apps(). Search for the string "icon_url" in the README on the main home page.

@mrDuplo
Copy link
Author

mrDuplo commented Dec 3, 2021

Hi,

I'm still not able to get the data I'm aiming for. I might be on the wrong track here...
My assumption is that that sending the listApps command to the TV doesn't provide working icon URLs, but the listLaunchPoints command does.

The goal is to dynamically display these icons in my app running on a RPi.

My fork: https://github.com/mrDuplo/PyWebOSTV
Link to API ref.: https://www.webosose.org/docs/reference/ls2-api/com-webos-service-applicationmanager/#launchpoints
External discussion on this topic: https://stackoverflow.com/questions/62712131/get-icon-of-installed-apps-on-webos-tv-lg

@supersaiyanmode
Copy link
Owner

  1. If something doesn't work, it is always helpful to describe how it doesn't work. What do you see? Do you get an exception? Do you get an object that doesn't have the required field -- if so, show us what the entire hierarchy in the object looks like.
  2. I remember seeing list_launch_points endpoint a long time ago, but I didn't include it in the library because it didn't have any value addition. Has something changed recently? My current stand is based on my recollection that listApps() already provides icons, and your assumption is wrong.
  3. list_apps() already returns the icon for the app IIRC. I still don't fully understand why you'd want launch_points. Instructions on how to extract these icons exists in the README -- as I said, CTRL+F for "icon" on the readme page. Did you try doing this? Did it not work? How exactly did it not work? What fields did you get in the result? What field/fields were you expecting?
  4. Assuming my stand above is wrong, and your assumption is correct (I don't have a TV to test now) -- I'd happily consider pulling in your changes. Also, I looked at your fork, you have a new class called LaunchPoint. Although, this looks cleaner, try the following for the initial iteration:
...
"return": lambda payload: payload.
}

Then say, print(application_control.list_launch_points()), and show us the returned dictionary. I typically use this as my starting point to understand what TV returns, and modify the expression accordingly to extract relevant fields.

@mrDuplo
Copy link
Author

mrDuplo commented Dec 4, 2021

I did try list_apps(). The resulting icon URIs could not be accessed from my computer.

However, your latest suggestions did give me the output I wanted:

{ 'subscribed': False, 'launchPoints': [ {'systemApp': True, 'removable': False, 'relaunch': False, 'largeIcon': 'http://'172.0.17.230:3000/resources/56b261a427827c78afecf92d780b4201b75e7ea2/icon_antenna.png','bgImages': [], 'userData': '', 'id': 'com.webos.app.livetv', 'title': 'Live TV', 'bgColor': '', 'iconColor': '#a3c125', 'appDescription': '', 'lptype': 'default', 'params': {}, 'bgImage': '/usr/palm/applications/com.webos.app.livetv/assets/livetv.png', 'unmovable': False, 'icon': 'http://'172.0.17.230:3000/resources/56b261a427827c78afecf92d780b4201b75e7ea2/icon_antenna.png', 'launchPointId': 'com.webos.app.livetv_default', 'favicon': '', 'imageForRecents': '', 'tileSize': 'normal'} ], 'caseDetail': {'change': ['NEWLIST_FROM_SDP']} }

I've revised my fork accordingly, returning only launchPoints. Not sure if the fields subscribed and caseDetail would be of interest.
The resulting icon URIs can indeed be accessed by my GUI app.

Let me know if you want me to do any specific testing in case you want this merged.
Your efforts are much appreciated! Thank you!

@supersaiyanmode
Copy link
Owner

Awesome!

  1. You mentioned that the URLs that got returned within list_apps() were not accessible? Could you maybe show me what the URL looks like? Please also include the code that shows how the response of list_apps() was used to extract the icon URL.
  2. I would definitely welcome your PR into this repo. However, I was thinking we restructure the exposed APIs such that these details are part of the same Application object. The users of this library need not know that there are two underlying APIs -- one returns the apps, the other resources associated with apps. They should ideally be unified and returned as a part of the Application object. What do you think?

@mrDuplo
Copy link
Author

mrDuplo commented Dec 4, 2021

The URLs from list_apps() looks similar to the URLs from list_launch_points.

APP_TITLE = "netflix"
appObj = ApplicationControl(client)

launchPoints = appObj.list_launch_points()
netflixLp = [x for x in launchPoints if APP_TITLE in x["title"].lower()][0]
netflixLpIconUrl = netflixLp["icon"]
print(netflixLpIconUrl)
netflixLpIconImg = requests.get(netflixLpIconUrl).content
print(netflixLpIconImg)

apps = appObj.list_apps()
netflixApp = [x for x in apps if APP_TITLE in x["title"].lower()][0]
netflixAppIconUrl = netflixApp["icon"]
print(netflixAppIconUrl)
netflixAppIconImg = requests.get(netflixAppIconUrl).content
print(netflixAppIconImg)

This gives the output: (some of the byte code emoved)

http://172.0.17.230:3000/resources/c961f51043428d19ed3a962a43700a551ed5e4ce/SMALL_APP_ICON.png
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00P\x00\x00\x00P\x08\x06\x00\x00\x00\x8e\x11\xf2\xad\x00\x00\n=iCCPicc\x00\x00x\xda\x9dSgTS\xe9\x16=\xf7\xde\xf4BK\x88\x80\x94KoR\x15\x08'

http://172.0.17.230:3000/resources/3475c51ddf96d09f6ad0188528fb38eafd8ba0c4/SMALL_APP_ICON.png
b''

I agree with your thoughts on restructuring.

@supersaiyanmode
Copy link
Owner

Perfect! Just as I thought -- I knew the URLs to the icons were available, I never actually checked if the resource served at that endpoint is valid. So, this is most likely a bug on the LG side.

As of now, to preserve your contributions, can you please send me a PR with LaunchPoints -- with perhaps the following changes?

  1. LaunchPoint objects should be constructed for each of the element in the array "launchPoints".
  2. Perhaps you can revert the lambda to the way it was before.

Thanks so much for your contribution! Cheers

@supersaiyanmode
Copy link
Owner

Hi @mrDuplo, pinging here again to see if you'd be open to creating a PR with your changes so we can preserve your contributions.

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

No branches or pull requests

2 participants