Пример #1
0
 def run(self):
     self.running = True
     self.downloader = fileDownloader.DownloadFile(
         self.url, localFileName=self.savename)
     if self.running == False: return
     try:
         if os.path.isfile(self.savename):
             self.downloader.resume(reportFunc=self.report)
         else:
             self.downloader.download(reportFunc=self.report)
     except Exception as inst:
         print traceback.format_exc()
         print inst
     self.running = False
Пример #2
0
def required(package, url, path):
    rq_path = path + '/' + package
    if not pathexist(rq_path):
        os.mkdir(rq_path)
        aurl = url.split('/')
        filename = aurl[len(aurl) - 1]
        filepath = rq_path + '/' + filename
        dw = fileDownloader.DownloadFile(url, filepath)
        dw.download()

        afile = filename.split('.')
        extl = afile[len(afile) - 1]

        if extl == 'zip':

            zf = zipfile.ZipFile(rq_path + '/' + filename, "r")
            for i in zf.namelist():
                zf.extract(i, path=rq_path)

        print(filename + ' was download')
Пример #3
0
def StartDowloader(url, name, mode, DFolder):

    origurl = None
    urlp = url
    if url.find("pornhd.com") > 0:
        origurl = url
        url = pornHD(url)
        urlp = url
        try:
            urlp = urlp.split("?")[-2]
        except:
            pass

        ext = urlp.split('.')[-1]
    else:
        url1 = url
        try:
            url1 = url.split('?')[-2]
        except:
            pass

        ext = url1.split('.')[-1]

    if len(ext) < 2 or len(ext) > 4:
        ext = "mp4"

    if urlp.find("openload.co") > 0:
        if mode == 6:
            LEN = len(name) - 4
            name = name[0:LEN]

    DF = xbmcaddon.Addon('plugin.video.kodilivetv').getSetting('download_path')

    if not DF == '':
        dpath = DF
    else:
        dpath = DFolder

    res = None

    if mode == 6:
        res = 'yes'

    import fileDownloader
    file = dpath + name + '.' + ext
    xbmc.log("Download URL --> " + str(url))
    xbmc.log("Download file --> " + str(file))
    downloader = fileDownloader.DownloadFile(url,
                                             file,
                                             origurl=origurl,
                                             res=res)

    notifica = 2
    loc1 = file + ".resume"
    loc2 = file + ".stopped"

    if os.path.isfile(loc2) and (mode == 7 or mode == 6):
        try:
            os.rename(loc2, loc1)
        except:
            pass

    if os.path.isfile(file):
        size = os.stat(file).st_size
    else:
        size = 0

    if os.path.isfile(file) and size > 0:
        if not mode == 59:
            Resume = TestDownload(file)
            if Resume:
                xbmc.executebuiltin(
                    'Notification(%s, %s, %d, %s)' %
                    (name, localizedString(10211).encode('utf-8'), 5000, icon))
                xbmc.executebuiltin("XBMC.Container.Refresh()")
                downloader.resume()
                notifica = 2
            else:
                notifica = 1
        else:
            downloader.resume()
    else:
        downloader.download()

    if notifica == 1:
        xbmc.executebuiltin(
            'Notification(%s, %s, %d, %s)' %
            (name, localizedString(10210).encode('utf-8'), 5000, icon))
    else:
        fullsize = size

        if os.path.isfile(loc1):
            fsize = ReadFile(loc1).replace("\r", "").split("\n")
            fullsize = int(fsize[0])

        if not int(size) == fullsize:
            xbmc.sleep(1000)
            xbmc.log("$$$  --  Download Retry --  $$$")
            xbmc.executebuiltin(
                'XBMC.RunPlugin(plugin://plugin.video.kodilivetv/?url=' +
                urllib.quote_plus(urlp) + '&name=' + name + '&mode=59)')
        else:
            if os.path.isfile(loc1):
                os.remove(loc1)
                xbmc.log("***  Download Complete ***")
                if not size == 0:
                    xbmc.executebuiltin(
                        'Notification(%s, %s, %d, %s)' %
                        (name, localizedString(10209).encode('utf-8'), 6000,
                         icon))
                else:
                    if not urlp.find("vizplay.org") > 0 and not urlp.find(
                            "openload.co") > 0:
                        xbmc.executebuiltin(
                            'Notification(%s, %s, %d, %s)' %
                            (name, 'ERROR : file not found!', 6000, icon))
                        if os.path.isfile(file):
                            os.remove(file)
                    else:
                        xbmc.executebuiltin(
                            'Notification(%s, %s, %d, %s)' %
                            (name, localizedString(10209).encode('utf-8'),
                             6000, icon))