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

download_service.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. import os,os.path,sys, datetime, traceback
  3. from kodiswift import Plugin, ListItem, storage
  4. from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE
  5. #from resources.lib import ContentSources, util
  6. #sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),"resources","lib","sources"))
  7. import resources.lib.Downloader as Downloader
  8. import sys,os, os.path, re
  9. import urlparse, requests
  10. from twisted.web import client
  11. from twisted.internet import reactor, defer, ssl, task
  12. #str(time.time())
  13. plugin = Plugin()
  14. plugin.load_addon_settings()
  15. download_dir = plugin.get_setting("general_download_dir",str)
  16. queue_dir = os.path.join(plugin.storage_path,"downloads)")
  17. if not os.path.exists(queue_dir):
  18. os.mkdir(queue_dir)
  19. class DownloadQueue(object):
  20. def __init__(self):
  21. self.flist=[]
  22. self.q=[]
  23. def check_queue(self):
  24. flist = os.listdir(queue_dir)
  25. print "Checking queue"
  26. def start_download(self):
  27. pass
  28. def download_ok(self):
  29. pass
  30. def download_err(self):
  31. pass
  32. queue = DownloadQueue()
  33. loop = task.LoopingCall(queue.check_queue)
  34. loop.start(2)
  35. reactor.run()