# -*- coding: utf-8 -*-
import os,os.path,sys, datetime, 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"))
import resources.lib.Downloader as Downloader
import sys,os, os.path, re
import urlparse, requests
from twisted.web import client
from twisted.internet import reactor, defer, ssl, task

#str(time.time())

plugin = Plugin()
plugin.load_addon_settings()
download_dir = plugin.get_setting("general_download_dir",str)
queue_dir = os.path.join(plugin.storage_path,"downloads)")
if not os.path.exists(queue_dir):
    os.mkdir(queue_dir)

class DownloadQueue(object):
    def __init__(self):
        self.flist=[]
        self.q=[]

    def check_queue(self):
        flist = os.listdir(queue_dir)
        print "Checking queue"

    def start_download(self):
        pass

    def download_ok(self):
        pass

    def download_err(self):
        pass


queue = DownloadQueue()
loop = task.LoopingCall(queue.check_queue)
loop.start(2)
reactor.run()
