Skip to content

Commit 18df77b

Browse files
support getting the formatted url to the icon (#61)
* support getting the formatted url to the icon * fix spacing * test for icon_url * Update README.rst * add icon_url to Application * fix readme example * update icon url tests * update icon_url test * fix readme example. * fix test.. * update readme. --------- Co-authored-by: Jeremy Carbaugh <39159+jcarbaugh@users.noreply.github.com>
1 parent f8a2037 commit 18df77b

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ You can also get the app's icon.
8888
>>> with open('hulu.png', 'w') as f:
8989
... f.write(hulu.icon)
9090

91+
>>> print hulu.icon_url
92+
http://0.0.0.0:8060/query/icon/2285
93+
9194
You can get the current running app.
9295
::
9396

roku/core.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def icon(self):
8585
if self.roku:
8686
return self.roku.icon(self)
8787

88+
@property
89+
def icon_url(self):
90+
if self.roku:
91+
return self.roku.icon_url(self)
92+
8893
def launch(self):
8994
if self.roku:
9095
self.roku.launch(self)
@@ -331,6 +336,9 @@ def power_state(self):
331336
def icon(self, app):
332337
return self._get(f"/query/icon/{app.id}")
333338

339+
def icon_url(self, app):
340+
return "http://%s:%s/query/icon/%s" % (self.host, self.port, app.id)
341+
334342
def launch(self, app, params={}):
335343
if app.roku and app.roku != self:
336344
raise RokuException("this app belongs to another Roku")

roku/tests/test_roku.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,10 @@ def test_launch(apps):
174174

175175
params = {'params': {'contentID': app.id}}
176176
assert call == ('POST', f'/launch/{app.id}', (), params)
177+
178+
179+
def test_icon_url(apps):
180+
181+
for app in apps:
182+
assert app.roku.icon_url(app) == f"http://0.0.0.0:8060/query/icon/{app.id}"
183+
assert app.icon_url == f"http://0.0.0.0:8060/query/icon/{app.id}"

0 commit comments

Comments
 (0)