addon.py fix spacing and adjust import directory

This commit is contained in:
Lukas Rusak 2016-05-05 00:26:06 -07:00
parent 137002f3ae
commit c8dc3eb0de

View file

@ -9,7 +9,7 @@ import urlparse
import sys
import os
from resources.moonlight import LibGameStream
from lib.moonlight import LibGameStream
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
@ -25,22 +25,22 @@ def build_url(query):
def index():
gs = LibGameStream(addon.getAddonInfo("path") + "/lib")
address = addon.getSetting("MOON_SERVER_IP")
if address == "0.0.0.0":
address = gs.discover_server()
if not gs.connect_server(address, os.path.join(addon_base_path, "keys")):
dialog = xbmcgui.Dialog()
dialog.ok("Error", "Failed connect to server (%s)" % (address))
return
if not gs.isPaired():
pin = "%d%d%d%d" % (random.randint(0,9), random.randint(0,9), random.randint(0,9), random.randint(0,9))
dialog = xbmcgui.Dialog()
dialog.notification("PIN code", "Insert the pin code in server: %s" % pin, xbmcgui.NOTIFICATION_INFO, 10000)
if gs.pair(pin):
dialog = xbmcgui.Dialog()
dialog.ok("Paired", "Succesfully paired")
@ -48,24 +48,24 @@ def index():
dialog = xbmcgui.Dialog()
dialog.ok("Error", "Failed to pair to server, try again")
return
for appId, name in gs.applist():
base_path = os.path.join(addon_base_path, "images")
if not os.path.exists(base_path):
os.makedirs(base_path)
poster_path = os.path.join(base_path, str(appId) + ".png")
if not os.path.isfile(poster_path):
gs.poster(appId, base_path)
xbmc.sleep(100)
xbmcplugin.addDirectoryItem(handle=addon_handle,
xbmcplugin.addDirectoryItem(handle=addon_handle,
url=build_url({"mode": "stream", "app": name}),
listitem=xbmcgui.ListItem(label=name, thumbnailImage=poster_path),
isFolder=False)
xbmcplugin.endOfDirectory(addon_handle)
def stream(app = None):