Kodi plugin to to play various online streams (mostly Latvian)

service.py 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. try:
  3. import wingdbstub
  4. except:
  5. pass
  6. import os,os.path,sys, urllib, traceback
  7. from kodiswift import Plugin, ListItem, storage
  8. from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE
  9. #from resources.lib import ContentSources, util
  10. #sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),"resources","lib","sources"))
  11. from resources.lib.content import playstreamproxy
  12. from downloadqueue import DownloadQueue
  13. #monitor = xbmc.Monitor()
  14. plugin = Plugin()
  15. plugin.load_addon_settings()
  16. autostart = plugin.get_setting("general_autostart", bool)
  17. queue_dir = os.path.join(xbmc.translatePath("special://temp"), "download_queue") if not CLI_MODE else "download_queue"
  18. download_queue = DownloadQueue(queue_dir)
  19. download_queue.clear() # TODO restarte nepabeigtos uzdevumus varbut?
  20. if autostart:
  21. xbmc.executebuiltin("RunAddon(plugin.video.playstream)")
  22. # view_mode = plugin.get_setting("view_mode", str)
  23. port = plugin.get_setting("general_port",int)
  24. start_proxy = plugin.get_setting("general_proxy",bool)
  25. redirect = plugin.get_setting("general_proxy_redirect",bool)
  26. multithread = plugin.get_setting("general_proxy_multithread",bool)
  27. workers = plugin.get_setting("general_proxy_workers",int)
  28. key = plugin.get_setting("general_proxy_key",str)
  29. host = "0.0.0.0"
  30. if start_proxy:
  31. plugin.notify("Starting playstreamproxy","Info",10000, xbmcgui.NOTIFICATION_INFO)
  32. try:
  33. if multithread:
  34. playstreamproxy.start2(host, port, redirect, key, workers)
  35. else:
  36. playstreamproxy.start(host, port, redirect, key)
  37. except Exception as e:
  38. xbmcgui.Dialog().ok("Error starting playstreamproxyserver",unicode(e))
  39. #plugin.notify(unicode(e), "Error", 10000, xbmcgui.NOTIFICATION_ERROR)
  40. traceback.print_exc()