addon.py fix spacing and adjust import directory
This commit is contained in:
parent
137002f3ae
commit
c8dc3eb0de
|
@ -9,7 +9,7 @@ import urlparse
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from resources.moonlight import LibGameStream
|
from lib.moonlight import LibGameStream
|
||||||
|
|
||||||
base_url = sys.argv[0]
|
base_url = sys.argv[0]
|
||||||
addon_handle = int(sys.argv[1])
|
addon_handle = int(sys.argv[1])
|
||||||
|
@ -25,22 +25,22 @@ def build_url(query):
|
||||||
|
|
||||||
def index():
|
def index():
|
||||||
gs = LibGameStream(addon.getAddonInfo("path") + "/lib")
|
gs = LibGameStream(addon.getAddonInfo("path") + "/lib")
|
||||||
|
|
||||||
address = addon.getSetting("MOON_SERVER_IP")
|
address = addon.getSetting("MOON_SERVER_IP")
|
||||||
if address == "0.0.0.0":
|
if address == "0.0.0.0":
|
||||||
address = gs.discover_server()
|
address = gs.discover_server()
|
||||||
|
|
||||||
if not gs.connect_server(address, os.path.join(addon_base_path, "keys")):
|
if not gs.connect_server(address, os.path.join(addon_base_path, "keys")):
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
dialog.ok("Error", "Failed connect to server (%s)" % (address))
|
dialog.ok("Error", "Failed connect to server (%s)" % (address))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not gs.isPaired():
|
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))
|
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 = xbmcgui.Dialog()
|
||||||
dialog.notification("PIN code", "Insert the pin code in server: %s" % pin, xbmcgui.NOTIFICATION_INFO, 10000)
|
dialog.notification("PIN code", "Insert the pin code in server: %s" % pin, xbmcgui.NOTIFICATION_INFO, 10000)
|
||||||
|
|
||||||
if gs.pair(pin):
|
if gs.pair(pin):
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
dialog.ok("Paired", "Succesfully paired")
|
dialog.ok("Paired", "Succesfully paired")
|
||||||
|
@ -48,24 +48,24 @@ def index():
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
dialog.ok("Error", "Failed to pair to server, try again")
|
dialog.ok("Error", "Failed to pair to server, try again")
|
||||||
return
|
return
|
||||||
|
|
||||||
for appId, name in gs.applist():
|
for appId, name in gs.applist():
|
||||||
base_path = os.path.join(addon_base_path, "images")
|
base_path = os.path.join(addon_base_path, "images")
|
||||||
|
|
||||||
if not os.path.exists(base_path):
|
if not os.path.exists(base_path):
|
||||||
os.makedirs(base_path)
|
os.makedirs(base_path)
|
||||||
|
|
||||||
poster_path = os.path.join(base_path, str(appId) + ".png")
|
poster_path = os.path.join(base_path, str(appId) + ".png")
|
||||||
|
|
||||||
if not os.path.isfile(poster_path):
|
if not os.path.isfile(poster_path):
|
||||||
gs.poster(appId, base_path)
|
gs.poster(appId, base_path)
|
||||||
xbmc.sleep(100)
|
xbmc.sleep(100)
|
||||||
|
|
||||||
xbmcplugin.addDirectoryItem(handle=addon_handle,
|
xbmcplugin.addDirectoryItem(handle=addon_handle,
|
||||||
url=build_url({"mode": "stream", "app": name}),
|
url=build_url({"mode": "stream", "app": name}),
|
||||||
listitem=xbmcgui.ListItem(label=name, thumbnailImage=poster_path),
|
listitem=xbmcgui.ListItem(label=name, thumbnailImage=poster_path),
|
||||||
isFolder=False)
|
isFolder=False)
|
||||||
|
|
||||||
xbmcplugin.endOfDirectory(addon_handle)
|
xbmcplugin.endOfDirectory(addon_handle)
|
||||||
|
|
||||||
def stream(app = None):
|
def stream(app = None):
|
||||||
|
|
Loading…
Reference in a new issue