# -*- coding: utf-8 -*- try: import wingdbstub except: pass import os,os.path,sys, urllib, traceback from kodiswift import Plugin, ListItem, storage from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE #from resources.lib import ContentSources, util #sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),"resources","lib","sources")) from resources.lib.content import playstreamproxy from downloadqueue import DownloadQueue #monitor = xbmc.Monitor() plugin = Plugin() plugin.load_addon_settings() autostart = plugin.get_setting("general_autostart", bool) queue_dir = os.path.join(xbmc.translatePath("special://temp"), "download_queue") if not CLI_MODE else "download_queue" download_queue = DownloadQueue(queue_dir) download_queue.clear() # TODO restarte nepabeigtos uzdevumus varbut? if autostart: xbmc.executebuiltin("RunAddon(plugin.video.playstream)") # view_mode = plugin.get_setting("view_mode", str) port = plugin.get_setting("general_port",int) start_proxy = plugin.get_setting("general_proxy",bool) redirect = plugin.get_setting("general_proxy_redirect",bool) multithread = plugin.get_setting("general_proxy_multithread",bool) workers = plugin.get_setting("general_proxy_workers",int) key = plugin.get_setting("general_proxy_key",str) host = "0.0.0.0" if start_proxy: plugin.notify("Starting playstreamproxy","Info",10000, xbmcgui.NOTIFICATION_INFO) try: if multithread: playstreamproxy.start2(host, port, redirect, key, workers) else: playstreamproxy.start(host, port, redirect, key) except Exception as e: xbmcgui.Dialog().ok("Error starting playstreamproxyserver",unicode(e)) #plugin.notify(unicode(e), "Error", 10000, xbmcgui.NOTIFICATION_ERROR) traceback.print_exc()