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

service.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. host = "localhost"
  26. if start_proxy:
  27. plugin.notify("Starting playstreamproxy","Info",10000, xbmcgui.NOTIFICATION_INFO)
  28. try:
  29. playstreamproxy.start(host, port)
  30. except Exception as e:
  31. xbmcgui.Dialog().ok("Error starting playstreamproxyserver",unicode(e))
  32. #plugin.notify(unicode(e), "Error", 10000, xbmcgui.NOTIFICATION_ERROR)
  33. traceback.print_exc()