Exemplo n.º 1
0
 def createProcessDialog(self):
     self.__oDialog = xbmcgui.DialogProgressBG()
     self.__oDialog.create('Download')
     #xbmc.sleep(1000)
     return self.__oDialog
Exemplo n.º 2
0
def UptomyAccount():
    addons = addon()

    if (addons.getSetting('hoster_uptobox_username')
            == '') and (addons.getSetting('hoster_uptobox_password') == ''):
        return
    oInputParameterHandler = cInputParameterHandler()
    sMediaUrl = oInputParameterHandler.getValue('sMediaUrl')

    oPremiumHandler = cPremiumHandler('uptobox')

    sHtmlContent = oPremiumHandler.GetHtml(URL_MAIN)
    cookies = GestionCookie().Readcookie('uptobox')

    aResult = re.search('<form id="fileupload" action="([^"]+)"', sHtmlContent,
                        re.DOTALL)
    if (aResult):
        UPurl = aResult.group(1).replace('upload?', 'remote?')

        if UPurl.startswith('//'):
            UPurl = 'https:' + UPurl

        fields = {'urls': '["' + sMediaUrl + '"]'}
        mpartdata = MPencode(fields)

        req = urllib2.Request(UPurl, mpartdata[1], headers)
        req.add_header('Content-Type', mpartdata[0].replace(',', ';'))
        req.add_header('Cookie', cookies)
        req.add_header('Content-Length', len(mpartdata[1]))

        #penible ce dialog auth
        xbmc.executebuiltin("Dialog.Close(all,true)")
        xbmcgui.Dialog().notification('Requete envoyé',
                                      'vous pouvez faire autre chose',
                                      xbmcgui.NOTIFICATION_INFO, 4000, False)

        try:
            rep = urllib2.urlopen(req)
        except urllib2.URLError, e:
            return ''

        sHtmlContent = rep.read()
        rep.close()

        sPattern = '{"id":.+?,(?:"size":|"progress":)([0-9]+)'
        oParser = cParser()
        aResult = oParser.parse(sHtmlContent, sPattern)
        if (aResult[0] == True):
            total = aResult[1][0]
            del aResult[1][0]

            dialog = xbmcgui.DialogProgressBG()
            dialog.create(SITE_NAME,
                          'Transfert de fichiers sur votre compte Uptobox')

            for aEntry in aResult[1]:
                dialog.update(
                    int(aEntry) * 100 / int(total), 'Upload en cours...')

                xbmc.sleep(500)
            dialog.close()

        else:
            #penible ce dialog auth
            xbmc.executebuiltin("Dialog.Close(all,true)")
            xbmcgui.Dialog().notification('Info upload', 'Fichier introuvable',
                                          xbmcgui.NOTIFICATION_INFO, 2000,
                                          False)