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

download_service.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- coding: utf-8 -*-
  2. try:
  3. import wingdbstub
  4. except:
  5. pass
  6. import os,os.path,sys, datetime, traceback
  7. from kodiswift import Plugin, ListItem, storage
  8. from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE
  9. sys.path.append(os.path.join(os.path.dirname(__file__), "resources", "lib"))
  10. #from resources.lib import ContentSources, util
  11. #sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),"resources","lib","sources"))
  12. from twisted.web import client
  13. from twisted.internet import reactor, defer, ssl, task
  14. import content.Downloader as Downloader
  15. import sys,os, os.path, re
  16. import urlparse, requests
  17. print "twisted imported"
  18. #str(time.time())
  19. plugin = Plugin()
  20. plugin.load_addon_settings()
  21. download_dir = plugin.get_setting("general_download_dir",str)
  22. queue_dir = os.path.join(plugin.storage_path,"downloads)")
  23. if not os.path.exists(queue_dir):
  24. os.mkdir(queue_dir)
  25. class DownloadQueue(object):
  26. def __init__(self):
  27. self.flist=[]
  28. self.q=[]
  29. def check_queue(self):
  30. print "check_queue"
  31. flist = os.listdir(queue_dir)
  32. print "Checking queue"
  33. def start_download(self):
  34. pass
  35. def download_ok(self):
  36. pass
  37. def download_err(self):
  38. pass
  39. def notify(text, title="Info", time=10000):
  40. if isinstance(text, unicode):
  41. text = text.encode("utf8")
  42. #xbmc.executebuiltin('Notification(Hello World,This is a simple example of notifications,5000,/script.hellow.world.png)')
  43. xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%("Info", text, time, xbmcgui.NOTIFICATION_INFO))
  44. queue = DownloadQueue()
  45. loop = task.LoopingCall(queue.check_queue)
  46. loop.start(2)
  47. reactor.run()