Skip to content

Commit

Permalink
Merge pull request #40 from bfayers/retrieve_appslist_meaningful
Browse files Browse the repository at this point in the history
Modify get_apps to return a more meaningful dictionary.
  • Loading branch information
florianholzapfel authored Jun 7, 2020
2 parents 78ffbed + 4243e31 commit 0d8a5c1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion panasonic_viera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import asyncio
import aiohttp.web
from http import HTTPStatus
import re
try:
from urllib.request import urlopen, Request, HTTPError, build_opener, HTTPHandler
except:
Expand Down Expand Up @@ -658,7 +659,13 @@ def get_apps(self):
res = self.soap_request(URL_CONTROL_NRC, URN_REMOTE_CONTROL,
'X_GetAppList', None)

return res
apps = res.split("vc_app")[1:]
app_list = {}
for app in apps:
prod_id = re.search('(?<=product_id\=)(.*?)(?=&apos;)', app).group(0)
name = re.search('(?<='+prod_id+'&apos;)(.*?)(?=&apos;)', app).group(0)
app_list[name] = prod_id
return app_list

def get_vector_info(self):
"""Return the vector info on the TV"""
Expand Down

0 comments on commit 0d8a5c1

Please sign in to comment.