コード例 #1
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
    def StartDownloadOneFile(self, meta=[]):
        VSlog('StartDownloadOneFile')
        self.__oConfig.showInfo("TvWatch", VSlang(30514), 5)
        if ReadSingleDatabase('download_status') == "InProgress":
            self.__oConfig.showInfo('TvWatch', VSlang(30509))
            return
        oInputParameterHandler = cInputParameterHandler()

        meta = {}
        meta['sMovieTitle'] = oInputParameterHandler.getValue('sMovieTitle')
        meta['sMainUrl'] = oInputParameterHandler.getValue('sMainUrl')
        meta['sItemUrl'] = oInputParameterHandler.getValue('sItemUrl')
        meta['sThumbnail'] = oInputParameterHandler.getValue('sThumbnail')
        meta['sNextUrl'] = oInputParameterHandler.getValue('sNextUrl')
        meta['sType'] = oInputParameterHandler.getValue('sType')
        meta['sQual'] = oInputParameterHandler.getValue('sQual')
        meta['refresh'] = oInputParameterHandler.getValue('refresh')
        meta['sEncodeUrl'] = oInputParameterHandler.getValue('sEncodeUrl')
        meta['sBaseUrl'] = oInputParameterHandler.getValue('sBaseUrl')

        needShowHosters = oInputParameterHandler.getValue('needShowHosters')

        if needShowHosters == 'True':
            try:
                from resources.sites.server import showHosters
                params = showHosters(meta, False)
            except Exception, e:
                VSlog("StartDownloadOneFile showHosters ERROR: " + e.message)
コード例 #2
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
    def download(self,
                 sDBUrl,
                 sTitle,
                 sDownloadPath,
                 sThumbnail,
                 sMainUrl,
                 FastMode=True):
        VSlog("Telechargement " + str(sDBUrl))
        # if self.isDownloading():
        #     self.__oConfig.showInfo('TvWatch', VSlang(30509))
        #     return False

        #resolve url
        oHoster = cHosterGui().checkHoster(sDBUrl)
        oHoster.setUrl(sDBUrl)
        aLink = oHoster.getMediaLink()

        if (aLink[0] == True):
            sUrl = aLink[1]
        else:
            VSlog('Lien non resolvable')
            self.__oConfig.showInfo('TvWatch', VSlang(30510))
            return False

        if (not sUrl.startswith('http')
            ) or sUrl.split('|')[0].endswith('.m3u8'):
            return False

        try:
            if '.' in sUrl:
                a = sUrl.rfind('.')
                sDownloadPath += sUrl[a:]

            #background download task
            if FastMode:
                cDownloadProgressBar(title=sTitle,
                                     url=sUrl,
                                     Dpath=sDownloadPath,
                                     icon=sThumbnail,
                                     mainUrl=sMainUrl,
                                     FastMode=True).start()
            else:
                cDownloadProgressBar(title=sTitle,
                                     url=sUrl,
                                     Dpath=sDownloadPath,
                                     icon=sThumbnail,
                                     mainUrl=sMainUrl).start()

            VSlog("Telechargement ok")

        except Exception, e:
            VSlog("Telechargement impossible " + e.message)
            self.__oConfig.showInfo('TvWatch', VSlang(30508))
            return False
コード例 #3
0
 def checkupdate(self):
     VSlog("checkupdate")
     version = self.oConfig.getAddonVersion()
     try:
         sRequest = '?client_id=' + self.client_id + '&client_secret=' + self.client_secret
         sUrl = 'https://raw.githubusercontent.com/tvwatch-kodi/TvWatch/master/source/changelog.txt'
         oRequest =  urllib2.Request(sUrl + sRequest)
         oResponse = urllib2.urlopen(oRequest)
         sContent = oResponse.read()
         if "Current Version" in sContent:
             sContent = sContent[sContent.find("Current Version"):]
             if " - " in sContent:
                 sContent = sContent[:sContent.find(" - ")]
                 sContent = sContent.replace("Current Version","")
                 sContent = sContent.replace(" ","")
                 sContent = sContent.replace(".","")
                 newVersion = int(sContent)
                 currentVersion = int(version.replace(".",""))
                 VSlog("checkupdate New Version: " + str(newVersion))
                 VSlog("checkupdate Current Version: " + str(currentVersion))
                 self.oConfig.setSetting('service_time', str(datetime.datetime.now()))
                 if newVersion > currentVersion:
                     WriteSingleDatabase('home_update', "true")
                     dialog = self.oConfig.showInfo("TvWatch", VSlang(30418))
                     VSupdate()
                     return True
                 else:
                     #self.oConfig.showInfo('TvWatch', 'Fichier a jour')
                     WriteSingleDatabase('home_update', "false")
     except Exception, e:
         self.oConfig.error(self.oConfig.getlanguage(30205))
         VSlog("checkupdate ERROR: " + e.message)
コード例 #4
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
    def run(self):

        try:
            #Recuperation url simple
            url = self.__sUrl.split('|')[0]
            #Recuperation des headers du lien
            headers = {}
            if len(self.__sUrl.split('|')) > 1:
                u = self.__sUrl.split('|')[1].split('&')
                for i in u:
                    headers[i.split('=')[0]] = i.replace(
                        i.split('=')[0] + '=', '')

            #Rajout du user-agent si abscent
            if not ('User-Agent' in headers):
                headers[
                    'User-Agent'] = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'

            req = urllib2.Request(url, None, headers)

            self.oUrlHandler = urllib2.urlopen(req, timeout=30)
            #self.__instance = repr(self)
            self.file = xbmcvfs.File(self.__fPath, 'w')
        except Exception, e:
            VSlog("download run error " + e.message + " URL " + self.__sUrl)
            self.__oConfig.showInfo('TvWatch', VSlang(30508))
            return
コード例 #5
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
    def RemoveDownload(self):
        self.__oConfig.showInfo("TvWatch", VSlang(30514), 5)
        oInputParameterHandler = cInputParameterHandler()
        sFullTitle = oInputParameterHandler.getValue('sFullTitle')

        oDialog = self.__oConfig.createDialogYesNo(VSlang(30512))
        if (oDialog == 1):
            db = cDb()
            aEntry = db.get_downloadFromTitle(sFullTitle)
            if aEntry != []:
                sPath = aEntry[2]
                sPath = db.str_deconv(sPath)
                try:
                    xbmcvfs.delete(sPath)
                    db.del_download(sFullTitle)
                    self.__oConfig.showInfo('TvWatch', VSlang(30511))
                    self.__oConfig.update()
                except Exception, e:
                    VSlog("DelFile Error " + e.message)
コード例 #6
0
 def cC0OO(self):
     VSlog('cC0OO checks')
     o0OoOoOO00 = 0
     self.cC = self.oConfig.getSetting(uc('dHZXYXRjaENvZGU='))
     I11i = False
     while not self.iCV():
         VSlog("cC: " + self.cC)
         self.cC = self.oConfig.createDialogNum(VSlang(int(uc('MzA0MjE='))))
         I11i = True
         o0OoOoOO00 += 1
         if self.cC == '' or o0OoOoOO00 >= 3:
             return False
     if self.pU:
         return True
     if self.iEDV() and self.iANIU():
         if I11i:
             cGui().showInfo(
                 VSlang(int(uc('MzAzMDY='))) % self.p,
                 VSlang(int(uc('MzA0NDI='))) % self.aD, 7)
         return True
     else:
         return False
         if 64 - 64: OOooo000oo0.i1 * ii1IiI1i % IIIiiIIii
コード例 #7
0
 def iANIU(self):
     oo0O000OoO = True
     i1iiIIiiI111 = self.oConfig.getSetting(uc('aXNQbGF5aW5n'))
     i1iiIIiiIlll = self.oConfig.getSetting(uc('bXlTZWxmUGxheQ=='))
     if i1iiIIiiI111 == '':
         self.oConfig.setSetting(uc('aXNQbGF5aW5n'), self.cIP)
     else:
         if int(self.cIP) > int(i1iiIIiiI111) and i1iiIIiiIlll != 'True':
             self.oConfig.setSetting(uc('aXNQbGF5aW5n'), self.cIP)
             VSlog('iANIU NOK !')
             cGui().showInfo(uc('QXV0aGVudGlmaWNhdGlvbg=='),
                             VSlang(int(uc('MzA0Mzc='))), 3)
             oo0O000OoO = False
     return oo0O000OoO
コード例 #8
0
ファイル: cast.py プロジェクト: ali-zakaria/TvWatch-Ori
    def checkLocalCast(self):
        if not self.isApplicable() or self.oConfig.getSetting(
                'castPlay') == DISABLE:
            return True
        packageName = 'de.stefanpledl.localcast'
        path = self.oConfig.getAddonPath().split(
            "org.xbmc.kodi")[0] + packageName
        if not os.path.exists(path):
            if self.oConfig.createDialogYesNo(VSlang(30455)):
                app = 'com.android.vending'
                intent = 'android.intent.action.VIEW'
                dataType = ''
                dataURI = 'market://details?id=' + packageName

                cmd = 'StartAndroidActivity("%s", "%s", "%s", "%s")' % (
                    app, intent, dataType, dataURI)
                try:
                    xbmc.executebuiltin(cmd)
                except:
                    self.oConfig.log("Can't start Google play App")
                    self.oConfig.error(VSlang(30456))
                return False
        return True
コード例 #9
0
 def iEDV(self):
     from datetime import date
     II1iI, i1iIii1Ii1II, i1I1Iiii1111 = self.cED.replace(" ",
                                                          "").split("/")
     i11 = date(int(i1I1Iiii1111), int(i1iIii1Ii1II), int(II1iI))
     I11 = self.oConfig.getCurrentDate()
     if i11 < I11:
         VSlog('iEDV NOK !')
         cGui().showInfo(uc('QXV0aGVudGlmaWNhdGlvbg=='),
                         VSlang(int(uc('MzA0NTA='))), 3)
         return False
     else:
         if 98 - 98: I1111 * o0o0Oo0oooo0 / I1I1i1 * I1I1i1 / ooO0OO000o
         self.aD = str((i11 - I11).days)
         self.oConfig.setSetting(uc('ZXhwaXJhdGlvbkRhdGU='), self.aD)
         return True
         if 11 - 11: IiII1IiiIiI1 % ii1IiI1i - iIiiiI1IiI1I1
コード例 #10
0
 def __getResume(self):
     self.oConfig.log('__getResume')
     meta = {}
     meta['title'] = self.sTitle
     time = 0.0
     try:
         data = self.db.get_resume(meta)
         if data != []:
             time = int(float(data[0][2]))
             self.oConfig.log('seekTime ' + str(time) + 's')
             if self.isCasting:
                 m, s = divmod(time, 60)
                 h, m = divmod(m, 60)
                 cGui().showInfo(
                     "TvWatch",
                     VSlang(30453) + " %d:%02d:%02d" % (h, m, s))
     except Exception, e:
         self.oConfig.log('__getResume ERROR: ' + e.message)
コード例 #11
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
    def StopDownload(self):
        self.__oConfig.showInfo("TvWatch", VSlang(30514), 5)
        cDownloadProgressBar().StopAll()
        WriteSingleDatabase('download_status', 'NotStarted')
        oInputParameterHandler = cInputParameterHandler()
        sFullTitle = oInputParameterHandler.getValue('sFullTitle')

        db = cDb()
        aEntry = db.get_downloadFromTitle(sFullTitle)
        if aEntry != []:
            if aEntry[4] == "InProgress":
                meta = {}
                meta['title'] = db.str_deconv(aEntry[1])
                meta['path'] = db.str_deconv(aEntry[2])
                meta['icon'] = aEntry[3]
                meta['status'] = "NotStarted"
                meta['sMainUrl'] = aEntry[5]
                db.update_download(meta)
        self.__oConfig.update()
コード例 #12
0
 def __getResume(self):
     self.oConfig.log('__getResume')
     meta = {}
     meta['title'] = self.sTitle
     try:
         data = self.db.get_resume(meta)
         if data != []:
             time = float(data[0][2])
             self.seekTime(time)
             if self.isCasting:
                 m, s = divmod(time, 60)
                 h, m = divmod(m, 60)
                 cGui().showInfo(
                     "TvWatch",
                     VSlang(30453) + " %d:%02d:%02d" % (h, m, s))
             # label = '%s %.2f minutes' % ('Reprendre:', time / 60)
             # oDialog = self.oConfig.createDialogYesNo(label)
             # if (oDialog == 1):
             #     self.seekTime(time)
     except Exception, e:
         self.oConfig.log('__getResume ERROR: ' + e.message)
コード例 #13
0
ファイル: cast.py プロジェクト: ali-zakaria/TvWatch-Ori
class cCast:
    def __init__(self):
        self.oConfig = cConfig()
        self.pfPath = os.path.join(self.oConfig.getUserDataPath(),
                                   'playercorefactory.xml')
        if not self.isApplicable():
            return

    def isApplicable(self):
        return xbmc.getCondVisibility("System.Platform.Android")

    def updateCast(self):
        if not self.isApplicable():
            return
        castPlay = self.oConfig.getSetting('castPlay')
        playercorefactoryPath = os.path.join(self.oConfig.getUserDataPath(),
                                             'playercorefactory.xml')
        playercorefactoryExists = xbmcvfs.exists(playercorefactoryPath)
        configChanged = False
        if playercorefactoryExists and castPlay == DISABLE:
            xbmcvfs.delete(playercorefactoryPath)
            configChanged = True
        if not playercorefactoryExists and castPlay == ENABLE:
            playercorefactory = os.path.join(self.oConfig.getRootPath(),
                                             'playercorefactory.xml')
            try:
                xbmcvfs.copy(playercorefactory, playercorefactoryPath)
                configChanged = True
            except Exception, e:
                self.oConfig.log("updateCast ERROR: " + e.message)
        if configChanged:
            if self.oConfig.createDialogYesNo(VSlang(30454)):
                try:
                    xbmc.executebuiltin("RestartApp")
                except:
                    self.oConfig.log(
                        "Can't use RestartApp fonction, call Quit instead")
                    xbmc.executebuiltin("Quit")
コード例 #14
0
class cRequestHandler:
    REQUEST_TYPE_GET = 0
    REQUEST_TYPE_POST = 1

    def __init__(self, sUrl):
		VSlog("Request handler URL: " + str(sUrl))
		self.__sUrl = sUrl
		self.__sRealUrl = ''
		self.__cType = self.REQUEST_TYPE_GET
		self.__aParamaters = {}
		self.__aParamatersLine = ''
		self.__aHeaderEntries = []
		self.removeBreakLines(True)
		self.removeNewLines(True)
		self.__setDefaultHeader()
		self.__timeout = 30
		self.__bRemoveNewLines = False
		self.__bRemoveBreakLines = False
		self.__sResponseHeader = ''
		self.__enableSSL = False
		self.__enableDNS = False

    def removeNewLines(self, bRemoveNewLines):
        self.__bRemoveNewLines = bRemoveNewLines

    def removeBreakLines(self, bRemoveBreakLines):
        self.__bRemoveBreakLines = bRemoveBreakLines

    def setRequestType(self, cType):
        self.__cType = cType

    def setTimeout(self, valeur):
        self.__timeout = valeur

    def enableSSL(self, valeur):
        self.__enableSSL = valeur

    def enableDNS(self, valeur):
        self.__enableDNS = valeur

    def addHeaderEntry(self, sHeaderKey, sHeaderValue):
        for sublist in self.__aHeaderEntries:
            if sHeaderKey in sublist:
                self.__aHeaderEntries.remove(sublist)
        aHeader = {sHeaderKey : sHeaderValue}
        self.__aHeaderEntries.append(aHeader)

    def addParameters(self, sParameterKey, mParameterValue):
        self.__aParamaters[sParameterKey] = mParameterValue

    def addParametersLine(self, mParameterValue):
        self.__aParamatersLine = mParameterValue

    #egg addMultipartFiled({'sess_id':sId,'upload_type':'url','srv_tmp_url':sTmp})
    def addMultipartFiled(self,fields ):
        mpartdata = MPencode(fields)
        self.__aParamatersLine = mpartdata[1]
        self.addHeaderEntry('Content-Type', mpartdata[0] )
        self.addHeaderEntry('Content-Length', len(mpartdata[1]))

    #Je sais plus si elle gere les doublons
    def getResponseHeader(self):
        return self.__sResponseHeader

    # url after redirects
    def getRealUrl(self):
        return self.__sRealUrl

    def GetCookies(self):
        if not self.__sResponseHeader:
            return ''
        if 'Set-Cookie' in self.__sResponseHeader:
            import re

            #cookie_string = self.__sResponseHeader.getheaders('set-cookie')
            #c = ''
            #for i in cookie_string:
            #    c = c + i + ', '
            c = self.__sResponseHeader.get('set-cookie')

            c2 = re.findall('(?:^|,) *([^;,]+?)=([^;,\/]+?);',c)
            if c2:
                cookies = ''
                for cook in c2:
                    cookies = cookies + cook[0] + '=' + cook[1]+ ';'
                cookies = cookies[:-1]
                return cookies
        return ''

    def request(self):
        #Supprimee car deconne si url contient ' ' et '+' en meme temps
        #self.__sUrl = self.__sUrl.replace(' ', '+')
        return self.__callRequest()

    def getRequestUri(self):
        return self.__sUrl + '?' + urllib.urlencode(self.__aParamaters)

    def __setDefaultHeader(self):
        self.addHeaderEntry('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0')
        self.addHeaderEntry('Accept-Language', 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3')
        self.addHeaderEntry('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')

    def __callRequest(self):
        if self.__enableDNS:
            socket.getaddrinfo = new_getaddrinfo

        if self.__aParamatersLine:
            sParameters = self.__aParamatersLine
        else:
            sParameters = urllib.urlencode(self.__aParamaters)

        if (self.__cType == cRequestHandler.REQUEST_TYPE_GET):
            if (len(sParameters) > 0):
                if (self.__sUrl.find('?') == -1):
                    self.__sUrl = self.__sUrl + '?' + str(sParameters)
                    sParameters = ''
                else:
                    self.__sUrl = self.__sUrl + '&' + str(sParameters)
                    sParameters = ''

        if (len(sParameters) > 0):
            oRequest = urllib2.Request(self.__sUrl, sParameters)
        else:
            oRequest = urllib2.Request(self.__sUrl)

        for aHeader in self.__aHeaderEntries:
            for sHeaderKey, sHeaderValue in aHeader.items():
                oRequest.add_header(sHeaderKey, sHeaderValue)

        sContent = ''
        try:

            if self.__enableSSL:
                VSlog('Retrying with SSL bug')
                import ssl
				# gcontext = ssl.SSLContext(ssl.PROTOCOL_TLS)
                gcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
                oResponse = urllib2.urlopen(oRequest, timeout = self.__timeout,context=gcontext)
            else:
                oResponse = urllib2.urlopen(oRequest, timeout = self.__timeout)

            sContent = oResponse.read()

            self.__sResponseHeader = oResponse.info()

            #compressed page ?
            if self.__sResponseHeader.get('Content-Encoding') == 'gzip':
                import zlib
                sContent = zlib.decompress(sContent, zlib.MAX_WBITS|16)

            #https://bugs.python.org/issue4773
            self.__sRealUrl = oResponse.geturl()
            self.__sResponseHeader = oResponse.info()

            oResponse.close()

        except urllib2.HTTPError, e:
            if e.code == 503:

                #Protected by cloudFlare ?
                from resources.lib import cloudflare
                if cloudflare.CheckIfActive(e.read()):
                    self.__sResponseHeader = e.hdrs
                    cookies = self.GetCookies()
                    VSlog( 'Page protegee par cloudflare')
                    CF = cloudflare.CloudflareBypass()
                    sContent = CF.GetHtml(self.__sUrl,e.read(),cookies,sParameters,oRequest.headers)
                    self.__sRealUrl, self.__sResponseHeader = CF.GetReponseInfo()
                else:
                    sContent = e.read()
                    self.__sRealUrl = e.geturl()
                    self.__sResponseHeader = e.headers()

            else:
                try:
                    VSlog("%s (%d),%s" % (VSlang(30205), e.code , self.__sUrl))
                    self.__sRealUrl = e.geturl()
                    self.__sResponseHeader = e.headers
                    sContent = e.read()
                except:
                    sContent = ''

            if not sContent:
                VSlog("%s 1: (%d),%s" % (VSlang(30205), e.code , self.__sUrl))
                if self.__enableDNS:
                    socket.getaddrinfo = prv_getaddrinfo
                    self.__enableDNS = False
                return ''

        except urllib2.URLError, e:
			VSlog("%s 2: (%s),%s" % (VSlang(30205), e.reason , self.__sUrl))
			if 'CERTIFICATE_VERIFY_FAILED' in str(e.reason) and self.__enableSSL == False:
				self.__enableSSL = True
				return self.__callRequest()
			# elif 'getaddrinfo failed' in str(e.reason) and self.__enableDNS == False:
			elif self.__enableDNS == False:
				self.__enableDNS = True
				return self.__callRequest()
コード例 #15
0
    def __callRequest(self):
        if self.__enableDNS:
            socket.getaddrinfo = new_getaddrinfo

        if self.__aParamatersLine:
            sParameters = self.__aParamatersLine
        else:
            sParameters = urllib.urlencode(self.__aParamaters)

        if (self.__cType == cRequestHandler.REQUEST_TYPE_GET):
            if (len(sParameters) > 0):
                if (self.__sUrl.find('?') == -1):
                    self.__sUrl = self.__sUrl + '?' + str(sParameters)
                    sParameters = ''
                else:
                    self.__sUrl = self.__sUrl + '&' + str(sParameters)
                    sParameters = ''

        if (len(sParameters) > 0):
            oRequest = urllib2.Request(self.__sUrl, sParameters)
        else:
            oRequest = urllib2.Request(self.__sUrl)

        for aHeader in self.__aHeaderEntries:
            for sHeaderKey, sHeaderValue in aHeader.items():
                oRequest.add_header(sHeaderKey, sHeaderValue)

        sContent = ''
        try:

            if self.__enableSSL:
                VSlog('Retrying with SSL bug')
                import ssl
				# gcontext = ssl.SSLContext(ssl.PROTOCOL_TLS)
                gcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
                oResponse = urllib2.urlopen(oRequest, timeout = self.__timeout,context=gcontext)
            else:
                oResponse = urllib2.urlopen(oRequest, timeout = self.__timeout)

            sContent = oResponse.read()

            self.__sResponseHeader = oResponse.info()

            #compressed page ?
            if self.__sResponseHeader.get('Content-Encoding') == 'gzip':
                import zlib
                sContent = zlib.decompress(sContent, zlib.MAX_WBITS|16)

            #https://bugs.python.org/issue4773
            self.__sRealUrl = oResponse.geturl()
            self.__sResponseHeader = oResponse.info()

            oResponse.close()

        except urllib2.HTTPError, e:
            if e.code == 503:

                #Protected by cloudFlare ?
                from resources.lib import cloudflare
                if cloudflare.CheckIfActive(e.read()):
                    self.__sResponseHeader = e.hdrs
                    cookies = self.GetCookies()
                    VSlog( 'Page protegee par cloudflare')
                    CF = cloudflare.CloudflareBypass()
                    sContent = CF.GetHtml(self.__sUrl,e.read(),cookies,sParameters,oRequest.headers)
                    self.__sRealUrl, self.__sResponseHeader = CF.GetReponseInfo()
                else:
                    sContent = e.read()
                    self.__sRealUrl = e.geturl()
                    self.__sResponseHeader = e.headers()

            else:
                try:
                    VSlog("%s (%d),%s" % (VSlang(30205), e.code , self.__sUrl))
                    self.__sRealUrl = e.geturl()
                    self.__sResponseHeader = e.headers
                    sContent = e.read()
                except:
                    sContent = ''

            if not sContent:
                VSlog("%s 1: (%d),%s" % (VSlang(30205), e.code , self.__sUrl))
                if self.__enableDNS:
                    socket.getaddrinfo = prv_getaddrinfo
                    self.__enableDNS = False
                return ''
コード例 #16
0
                    socket.getaddrinfo = prv_getaddrinfo
                    self.__enableDNS = False
                return ''

        except urllib2.URLError, e:
			VSlog("%s 2: (%s),%s" % (VSlang(30205), e.reason , self.__sUrl))
			if 'CERTIFICATE_VERIFY_FAILED' in str(e.reason) and self.__enableSSL == False:
				self.__enableSSL = True
				return self.__callRequest()
			# elif 'getaddrinfo failed' in str(e.reason) and self.__enableDNS == False:
			elif self.__enableDNS == False:
				self.__enableDNS = True
				return self.__callRequest()

        except Exception, e:
			VSlog("%s 3: (%s),%s" % (VSlang(30205), e.message , self.__sUrl))
			return ''

        if (self.__bRemoveNewLines == True):
            sContent = sContent.replace("\n","")
            sContent = sContent.replace("\r\t","")

        if (self.__bRemoveBreakLines == True):
            sContent = sContent.replace("&nbsp;","")

        if self.__enableDNS:
            socket.getaddrinfo = prv_getaddrinfo
            self.__enableDNS = False

        return sContent
コード例 #17
0
    def run(self, oGuiElement, title, sUrl, protectedLink='', quality=''):

        self.totalTime = 0
        self.currentTime = 0
        self.timeCast = 0
        self.theEnd = False
        self.sTitle = title
        self.Thumbnail = oGuiElement.getThumbnail()
        self.protectedLink = protectedLink
        self.clientID = self.db.get_clientID()
        self.mySqlDB = cMySqlDB()
        self.sQual = quality
        self.isCasting = (self.oConfig.getSetting('castPlay') == "1")
        self.playParams = None
        if "Episode" in title:
            self.sType = 'tvshow'
        else:
            self.sType = 'movie'

        sPluginHandle = cPluginHandler().getPluginHandle()

        oGui = cGui()
        item = oGui.createListItem(oGuiElement)
        item.setPath(oGuiElement.getMediaUrl())

        if not cCast().checkLocalCast():
            return False

        # meta = {'label': oGuiElement.getTitle(), 'title': oGuiElement.getTitle()}
        # item = xbmcgui.ListItem(path=sUrl, iconImage="DefaultVideo.png",  thumbnailImage=self.sThumbnail)
        # item.setInfo( type="Video", infoLabels= meta )

        #Sous titres
        if (self.Subtitles_file):
            try:
                item.setSubtitles(self.Subtitles_file)
                VSlog("Load SubTitle :" + str(self.Subtitles_file))
                self.SubtitleActive = True
            except:
                VSlog("Can't load subtitle :" + str(self.Subtitles_file))

        player_conf = self.oConfig.getSetting("playerPlay")
        player_conf = '0'

        #Si lien dash, methode prioritaire
        if sUrl.endswith('.mpd'):
            if isKrypton() == True:
                self.enable_addon("inputstream.adaptive")
                item.setProperty('inputstreamaddon', 'inputstream.adaptive')
                item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
                xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item)
                VSlog('Player use inputstream addon')
            else:
                VSerror('Nécessite kodi 17 minimum')
                return
        #1 er mode de lecture
        elif (player_conf == '0'):
            self.play(sUrl, item)
            VSlog('Player use Play() method')
        #2 eme mode non utilise
        elif (player_conf == 'neverused'):
            xbmc.executebuiltin("PlayMedia(" + sUrl + ")")
            VSlog('Player use PlayMedia() method')
        #3 eme mode (defaut)
        else:
            VSlog('sPluginHandle ' + str(sPluginHandle))
            VSlog('item ' + str(item))
            xbmcplugin.setResolvedUrl(sPluginHandle, True, item)
            #self.play(sUrl,item)
            VSlog('Player use setResolvedUrl() method')

        #Attend que le lecteur demarre, avec un max de 20s
        # attempt = 0
        # while not self.playBackEventReceived or attempt >= 20:
        #     attempt += 1
        #     xbmc.sleep(1000)

        attempt = 0
        while not self.playBackEventReceived:
            xbmc.sleep(1000)
            if attempt < 20:
                attempt += 1
            else:
                cGui().showError("TvWatch", "Playback ERROR")
                return False

        #active/desactive les sous titres suivant l'option choisie dans la config
        # if (self.SubtitleActive):
        #     if (self.oConfig.getSetting("srt-view") == 'true'):
        #         self.showSubtitles(True)
        #         cGui().showInfo("Sous titre charges", "Sous-Titres", 5)
        #     else:
        #         self.showSubtitles(False)
        #         cGui().showInfo("Sous titre charges, Vous pouvez les activer", "Sous-Titres", 15)

        # Remove buffering dialog !
        self.oConfig.hide_busy_dialog()

        self.__setResume()

        stop = False
        while self.isPlaying() and not self.forcestop:
            tt = self.__getTotalTime()
            ct = self.__getTime()
            if self.totalTime != tt:
                self.totalTime = tt
            if self.currentTime != ct:
                self.currentTime = ct
                try:
                    if self.currentTime > 3:
                        exec uc(
                            "c2VsZi5teVNxbERCLnVwZGF0ZUlQKHN0cihpbnQoc2VsZi5jdXJyZW50VGltZSkpLCBzZWxmLmNsaWVudElEKQ=="
                        )
                        self.__setResume(update=True)
                    if ((self.totalTime - self.currentTime < 60) or
                        (self.isCasting
                         and self.currentTime > 60)) and not stop:
                        if self.sType == 'tvshow':
                            from resources.sites.server import prepareNextEpisode
                            # cGui().showInfo("TvWatch", "Preparing next episode")
                            self.playParams = prepareNextEpisode(
                                self.sTitle, self.sQual, self.sType)
                        stop = True
                    if (self.totalTime - self.currentTime <
                            20) and not self.theEnd and not self.isCasting:
                        if self.sType == 'tvshow':
                            cGui().showInfo("TvWatch", VSlang(30439), 5)
                        self.theEnd = True
                except Exception, e:
                    self.oConfig.log('Run player ERROR: ' + e.message)
            xbmc.sleep(1000)
コード例 #18
0
ファイル: favourite.py プロジェクト: ali-zakaria/TvWatch-Ori
    def getFavourites(self):
        oGui = cGui()

        #Comptages des favoris
        row = cDb().get_favorite()

        compt = [0, 0, 0, 0, 0, 0, 0, 0]
        for i in row:

            compt[int(i[5])] = compt[int(i[5])] + 1

        # sTitle = '[COLOR khaki]Vous avez %s marque page[/COLOR]' % (len(row))
        # oOutputParameterHandler = cOutputParameterHandler()
        # oOutputParameterHandler.addParameter('siteUrl', 'http://')
        # oGui.addText(SITE_IDENTIFIER, sTitle)

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('sCat', '1')
        oGui.addDir(SITE_IDENTIFIER, 'getFav',
                    VSlang(30120) + ' (' + str(compt[1]) + ')', 'mark.png',
                    oOutputParameterHandler)  # Films

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('sCat', '2')
        oGui.addDir(SITE_IDENTIFIER, 'getFav',
                    VSlang(30121) + ' (' + str(compt[2]) + ')', 'mark.png',
                    oOutputParameterHandler)  # Series

        # oOutputParameterHandler = cOutputParameterHandler()
        # oOutputParameterHandler.addParameter('sCat', '3')
        # oGui.addDir(SITE_IDENTIFIER, 'getFav()', 'Pages', 'news.png', oOutputParameterHandler)

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('sCat', '6')
        oGui.addDir(SITE_IDENTIFIER, 'getFav',
                    VSlang(30117) + ' (' + str(compt[6]) + ')', 'mark.png',
                    oOutputParameterHandler)  # TV replay

        # oOutputParameterHandler = cOutputParameterHandler()
        # oOutputParameterHandler.addParameter('sCat', '4')
        # oGui.addDir(SITE_IDENTIFIER, 'getFav', 'Sources (' + str(compt[4]) + ')', 'mark.png', oOutputParameterHandler)

        # oOutputParameterHandler = cOutputParameterHandler()
        # oOutputParameterHandler.addParameter('sCat', '7')
        # oGui.addDir(SITE_IDENTIFIER, 'getFav', 'Recherche Visuelle (' + str(compt[7]) + ')', 'mark.png', oOutputParameterHandler)

        # oOutputParameterHandler = cOutputParameterHandler()
        # oOutputParameterHandler.addParameter('sCat', '5')
        # oGui.addDir(SITE_IDENTIFIER, 'getFav', 'Divers (' + str(compt[5]) + ')', 'mark.png', oOutputParameterHandler)

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('sAll', 'true')
        oGui.addDir(SITE_IDENTIFIER, 'delFavourites', VSlang(30209),
                    'trash.png', oOutputParameterHandler)

        #A virer dans les versions future, pour le moment c'est juste pr supprimer les liens bugges
        # if compt[0] > 0:
        #     oOutputParameterHandler = cOutputParameterHandler()
        #     oOutputParameterHandler.addParameter('sCat', '0')
        #     oGui.addDir(SITE_IDENTIFIER, 'getFav', '[COLOR red]Erreur /!\ lien a supprimer !!! (' + str(compt[0]) + ')[/COLOR]', 'mark.png', oOutputParameterHandler)

        oGui.setEndOfDirectory()
コード例 #19
0
    def run(self, playParams):
        self.totalTime = 0
        self.currentTime = 0
        self.timeCast = 0
        self.theEnd = False
        self.sTitle = playParams['title']
        self.Thumbnail = playParams['sThumbnail']
        self.sItemUrl = playParams['sItemUrl']
        self.mainUrl = playParams['sMainUrl']
        self.clientID = self.oConfig.getSetting('clientID')
        self.mySqlDB = cMySqlDB()
        self.sQual = playParams['sQual']
        self.isCasting = (self.oConfig.getSetting('castPlay') == "1")
        self.playParams = None
        if "Episode" in playParams['title']:
            self.sType = 'tvshow'
        elif (playParams['tv'] == "True"):
            self.sType = 'livetv'
        else:
            self.sType = 'movie'

        title = self.sTitle
        if "- Saison" in title:
            title = title[:title.find("- Saison")]
        elif "Saison" in title:
            title = title[:title.find("Saison")]

        sPluginHandle = cPluginHandler().getPluginHandle()

        oGui = cGui()
        item = oGui.createListItem(playParams['guiElement'])
        item.setPath(playParams['guiElement'].getMediaUrl())

        if not cCast().checkLocalCast():
            return False

        # meta = {'label': playParams['guiElement'].getTitle(), 'playParams['title']': playParams['guiElement'].getTitle()}
        # item = xbmcgui.ListItem(path=playParams['sUrlToPlay'], iconImage="DefaultVideo.png",  thumbnailImage=self.sThumbnail)
        # item.setInfo( type="Video", infoLabels= meta )

        #Sous titres
        if (self.Subtitles_file):
            try:
                item.setSubtitles(self.Subtitles_file)
                VSlog("Load SubTitle :" + str(self.Subtitles_file))
                self.SubtitleActive = True
            except:
                VSlog("Can't load subtitle :" + str(self.Subtitles_file))

        player_conf = self.oConfig.getSetting("playerPlay")
        player_conf = '0'

        VSlog('Run player. Version: ' + self.oConfig.getAddonVersion())
        VSlog('Title: ' + self.sTitle)
        VSlog('Item URL: ' + self.sItemUrl)
        VSlog('Main URL: ' + self.mainUrl)

        #Si lien dash, methode prioritaire
        if playParams['sUrlToPlay'].endswith('.mpd'):
            if isKrypton() == True:
                self.enable_addon("inputstream.adaptive")
                item.setProperty('inputstreamaddon', 'inputstream.adaptive')
                item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
                xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item)
                VSlog('Player use inputstream addon')
            else:
                VSerror('Nécessite kodi 17 minimum')
                return
        #1 er mode de lecture
        elif (player_conf == '0'):
            windowed = False
            startPos = -1
            self.play(playParams['sUrlToPlay'], item, windowed, startPos)
            VSlog('Player use Play() method')
        #2 eme mode non utilise
        elif (player_conf == 'neverused'):
            xbmc.executebuiltin("PlayMedia(" + playParams['sUrlToPlay'] + ")")
            VSlog('Player use PlayMedia() method')
        #3 eme mode (defaut)
        else:
            VSlog('sPluginHandle ' + str(sPluginHandle))
            VSlog('item ' + str(item))
            xbmcplugin.setResolvedUrl(sPluginHandle, True, item)
            #self.play(playParams['sUrlToPlay'],item)
            VSlog('Player use setResolvedUrl() method')

        #Attend que le lecteur demarre, avec un max de 20s
        # attempt = 0
        # while not self.playBackEventReceived or attempt >= 20:
        #     attempt += 1
        #     xbmc.sleep(1000)

        attempt = 0
        while not self.playBackEventReceived:
            xbmc.sleep(1000)
            if attempt < 30:
                attempt += 1
            else:
                cGui().showError("TvWatch", "Playback ERROR")
                return False

        exec uc("Xz0oc2VsZi5vQ29uZmlnLmdldFNldHRpbmcoImNsaWVudElEIikhPSIzNSIp")
        #active/desactive les sous titres suivant l'option choisie dans la config
        # if (self.SubtitleActive):
        #     if (self.oConfig.getSetting("srt-view") == 'true'):
        #         self.showSubtitles(True)
        #         cGui().showInfo("Sous titre charges", "Sous-Titres", 5)
        #     else:
        #         self.showSubtitles(False)
        #         cGui().showInfo("Sous titre charges, Vous pouvez les activer", "Sous-Titres", 15)

        # Add Movie to DB
        meta = {}
        meta['title'] = self.sTitle
        if self.db.get_resume(meta) == []:
            self.__setResume()

        seek = True
        stop = False
        while self.isPlaying() and not self.forcestop:
            tt = self.__getTotalTime()
            ct = self.__getTime()
            if self.totalTime != tt:
                self.totalTime = tt
            if self.currentTime != ct:
                self.currentTime = ct
                try:
                    if seek:
                        seekTime = self.__getResume()
                        self.seekTime(seekTime)
                        # Remove buffering dialog !
                        VS_hide_busy_dialog()
                        seek = False
                    if (self.currentTime > 3) and _:
                        exec uc(
                            "c2VsZi5teVNxbERCLnVwZGF0ZUlQKHN0cihpbnQoc2VsZi5jdXJyZW50VGltZSkpLCBzZWxmLmNsaWVudElEKQ=="
                        )
                        WriteSingleDatabase(uc('bXlTZWxmUGxheQ=='), 'True')
                        self.__setResume(update=True)
                    if self.sType != 'livetv':
                        if ((self.totalTime - self.currentTime < 60) or \
                            (self.isCasting and self.currentTime > 60)) and \
                            self.totalTime != 0.0 and \
                            not stop:
                            if self.sType == 'tvshow':
                                from resources.sites.server import prepareNextEpisode
                                # cGui().showInfo("TvWatch", "Preparing next episode")
                                self.playParams = prepareNextEpisode(
                                    self.sTitle, self.sQual, self.sType)
                            stop = True
                        if (self.totalTime - self.currentTime < 20) and \
                            not self.theEnd and \
                            self.totalTime != 0.0 and \
                            not self.isCasting:
                            if self.sType == 'tvshow' and self.playParams != None:
                                cGui().showInfo(title, VSlang(30439), 5)
                            self.theEnd = True
                except Exception, e:
                    self.oConfig.log('Run player ERROR: ' + e.message)
            xbmc.sleep(1000)
コード例 #20
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
        db.update_download(meta)
        WriteSingleDatabase("download_status", "NotStarted")

        #fait une pause pour fermer le Dialog
        xbmc.sleep(500)

        #if download done
        if (TotDown == iTotalSize) and (iTotalSize > 10000):
            try:
                self.__oConfig.showInfo(VSlang(30507), self.__sTitle)
                VSlog('Téléchargements Termine : %s' % self.__sTitle)
            except Exception, e:
                VSlog("_StartDownload Done error " + e.message)
        else:
            try:
                self.__oConfig.showInfo(VSlang(30506), self.__sTitle)
                VSlog('Téléchargements Arrete : %s' % self.__sTitle)
            except Exception, e:
                VSlog("_StartDownload Not Done error " + e.message)
            return

        # self.RefreshDownloadList()
        self.__oConfig.update()

    def __stateCallBackFunction(self, iDownsize, iTotalSize):
        iPercent = int(float(iDownsize * 100) / iTotalSize)
        self.__oDialog.update(
            iPercent, self.__sTitle,
            self.__formatFileSize(float(iDownsize)) + '/' +
            self.__formatFileSize(iTotalSize))
コード例 #21
0
ファイル: download.py プロジェクト: tvwatch-kodi/TvWatch
    def _StartDownload(self):
        WriteSingleDatabase("download_stop", "False")
        headers = self.oUrlHandler.info()

        db = cDb()

        iTotalSize = -1
        if "content-length" in headers:
            iTotalSize = int(headers["Content-Length"])

        chunk = 1024 * 1024
        TotDown = 0

        meta = {}
        meta['sMainUrl'] = self.__sMainUrl
        meta['title'] = self.__sTitle
        meta['path'] = self.__fPath
        meta['icon'] = self.__sThumbnail
        meta['status'] = "InProgress"

        db.insert_download(meta)
        WriteSingleDatabase('download_status', 'InProgress')

        #mise a jour pour info taille
        self.__oConfig.showInfo('TvWatch', VSlang(30505))
        self.__oDialog = self.createProcessDialog()
        self.currentTime = 0
        WriteSingleDatabase(uc('bXlTZWxmUGxheQ=='), 'True')
        self.__oConfig.update()
        while not self.processIsCanceled:
            self.currentTime += 1
            exec uc(
                "c2VsZi5teVNxbERCLnVwZGF0ZUlQKHN0cihpbnQoc2VsZi5jdXJyZW50VGltZSkpLCBzZWxmLmNsaWVudElEKQ=="
            )

            data = self.oUrlHandler.read(chunk)
            if not data:
                print 'DL err'
                break

            self.file.write(data)
            TotDown = TotDown + data.__len__()

            self.__stateCallBackFunction(TotDown, iTotalSize)
            if ReadSingleDatabase("download_stop") == "True":
                self.processIsCanceled = True

            #petite pause, ca ralentit le download mais evite de bouffer 100/100 ressources
            if not (self.__bFastMode):
                xbmc.sleep(300)

        self.oUrlHandler.close()
        self.file.close()
        self.__oDialog.close()

        exec uc("c2VsZi5teVNxbERCLnVwZGF0ZUlQKCIwIiwgc2VsZi5jbGllbnRJRCk=")
        WriteSingleDatabase(uc('aXNQbGF5aW5n'), "0")
        WriteSingleDatabase(uc('bXlTZWxmUGxheQ=='), 'False')

        meta['status'] = "Downloaded"
        db.update_download(meta)
        WriteSingleDatabase("download_status", "NotStarted")

        #fait une pause pour fermer le Dialog
        xbmc.sleep(500)

        #if download done
        if (TotDown == iTotalSize) and (iTotalSize > 10000):
            try:
                self.__oConfig.showInfo(VSlang(30507), self.__sTitle)
                VSlog('Téléchargements Termine : %s' % self.__sTitle)
            except Exception, e:
                VSlog("_StartDownload Done error " + e.message)
コード例 #22
0
class cPlayer(xbmc.Player):
    def __init__(self, *args):
        self.db = cDb()
        self.oConfig = cConfig()
        sPlayerType = self.__getPlayerType()
        xbmc.Player.__init__(self, sPlayerType)

        self.Subtitles_file = []
        self.SubtitleActive = False

        oInputParameterHandler = cInputParameterHandler()
        #aParams = oInputParameterHandler.getAllParameter()
        #xbmc.log(str(aParams))

        self.sHosterIdentifier = oInputParameterHandler.getValue(
            'sHosterIdentifier')
        self.sTitle = oInputParameterHandler.getValue('sTitle')
        #self.sSite = oInputParameterHandler.getValue('site')
        self.sSite = oInputParameterHandler.getValue('siteUrl')
        self.sThumbnail = xbmc.getInfoLabel('ListItem.Art(thumb)')

        self.playBackEventReceived = False
        self.playBackStoppedEventReceived = False
        self.forcestop = False

        VSlog("player initialized")

    def clearPlayList(self):
        oPlaylist = self.__getPlayList()
        oPlaylist.clear()

    def __getPlayList(self):
        return xbmc.PlayList(xbmc.PLAYLIST_VIDEO)

    def addItemToPlaylist(self, oGuiElement):
        oGui = cGui()
        oListItem = oGui.createListItem(oGuiElement)
        self.__addItemToPlaylist(oGuiElement, oListItem)

    def __addItemToPlaylist(self, oGuiElement, oListItem):
        oPlaylist = self.__getPlayList()
        oPlaylist.add(oGuiElement.getMediaUrl(), oListItem)

    def AddSubtitles(self, files):
        if isinstance(files, basestring):
            self.Subtitles_file.append(files)
        else:
            self.Subtitles_file = files

    def run(self, oGuiElement, title, sUrl, protectedLink='', quality=''):

        self.totalTime = 0
        self.currentTime = 0
        self.timeCast = 0
        self.theEnd = False
        self.sTitle = title
        self.Thumbnail = oGuiElement.getThumbnail()
        self.protectedLink = protectedLink
        self.clientID = self.db.get_clientID()
        self.mySqlDB = cMySqlDB()
        self.sQual = quality
        self.isCasting = (self.oConfig.getSetting('castPlay') == "1")
        self.playParams = None
        if "Episode" in title:
            self.sType = 'tvshow'
        else:
            self.sType = 'movie'

        sPluginHandle = cPluginHandler().getPluginHandle()

        oGui = cGui()
        item = oGui.createListItem(oGuiElement)
        item.setPath(oGuiElement.getMediaUrl())

        if not cCast().checkLocalCast():
            return False

        # meta = {'label': oGuiElement.getTitle(), 'title': oGuiElement.getTitle()}
        # item = xbmcgui.ListItem(path=sUrl, iconImage="DefaultVideo.png",  thumbnailImage=self.sThumbnail)
        # item.setInfo( type="Video", infoLabels= meta )

        #Sous titres
        if (self.Subtitles_file):
            try:
                item.setSubtitles(self.Subtitles_file)
                VSlog("Load SubTitle :" + str(self.Subtitles_file))
                self.SubtitleActive = True
            except:
                VSlog("Can't load subtitle :" + str(self.Subtitles_file))

        player_conf = self.oConfig.getSetting("playerPlay")
        player_conf = '0'

        #Si lien dash, methode prioritaire
        if sUrl.endswith('.mpd'):
            if isKrypton() == True:
                self.enable_addon("inputstream.adaptive")
                item.setProperty('inputstreamaddon', 'inputstream.adaptive')
                item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
                xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item)
                VSlog('Player use inputstream addon')
            else:
                VSerror('Nécessite kodi 17 minimum')
                return
        #1 er mode de lecture
        elif (player_conf == '0'):
            self.play(sUrl, item)
            VSlog('Player use Play() method')
        #2 eme mode non utilise
        elif (player_conf == 'neverused'):
            xbmc.executebuiltin("PlayMedia(" + sUrl + ")")
            VSlog('Player use PlayMedia() method')
        #3 eme mode (defaut)
        else:
            VSlog('sPluginHandle ' + str(sPluginHandle))
            VSlog('item ' + str(item))
            xbmcplugin.setResolvedUrl(sPluginHandle, True, item)
            #self.play(sUrl,item)
            VSlog('Player use setResolvedUrl() method')

        #Attend que le lecteur demarre, avec un max de 20s
        # attempt = 0
        # while not self.playBackEventReceived or attempt >= 20:
        #     attempt += 1
        #     xbmc.sleep(1000)

        attempt = 0
        while not self.playBackEventReceived:
            xbmc.sleep(1000)
            if attempt < 20:
                attempt += 1
            else:
                cGui().showError("TvWatch", "Playback ERROR")
                return False

        #active/desactive les sous titres suivant l'option choisie dans la config
        # if (self.SubtitleActive):
        #     if (self.oConfig.getSetting("srt-view") == 'true'):
        #         self.showSubtitles(True)
        #         cGui().showInfo("Sous titre charges", "Sous-Titres", 5)
        #     else:
        #         self.showSubtitles(False)
        #         cGui().showInfo("Sous titre charges, Vous pouvez les activer", "Sous-Titres", 15)

        # Remove buffering dialog !
        self.oConfig.hide_busy_dialog()

        self.__setResume()

        stop = False
        while self.isPlaying() and not self.forcestop:
            tt = self.__getTotalTime()
            ct = self.__getTime()
            if self.totalTime != tt:
                self.totalTime = tt
            if self.currentTime != ct:
                self.currentTime = ct
                try:
                    if self.currentTime > 3:
                        exec uc(
                            "c2VsZi5teVNxbERCLnVwZGF0ZUlQKHN0cihpbnQoc2VsZi5jdXJyZW50VGltZSkpLCBzZWxmLmNsaWVudElEKQ=="
                        )
                        self.__setResume(update=True)
                    if ((self.totalTime - self.currentTime < 60) or
                        (self.isCasting
                         and self.currentTime > 60)) and not stop:
                        if self.sType == 'tvshow':
                            from resources.sites.server import prepareNextEpisode
                            # cGui().showInfo("TvWatch", "Preparing next episode")
                            self.playParams = prepareNextEpisode(
                                self.sTitle, self.sQual, self.sType)
                        stop = True
                    if (self.totalTime - self.currentTime <
                            20) and not self.theEnd and not self.isCasting:
                        if self.sType == 'tvshow':
                            cGui().showInfo("TvWatch", VSlang(30439), 5)
                        self.theEnd = True
                except Exception, e:
                    self.oConfig.log('Run player ERROR: ' + e.message)
            xbmc.sleep(1000)

        if not self.playBackStoppedEventReceived:
            self.onPlayBackStopped()

        if self.playParams != None and self.isCasting:
            if self.oConfig.createDialogYesNo(VSlang(30457)):
                self.theEnd = True

        if self.playParams != None and self.theEnd:
            from resources.lib.gui.hoster import cHosterGui
            cHosterGui().play(self.playParams)

        #Uniquement avec la lecture avec play()
        #if (player_conf == '0'):
        #r = xbmcplugin.addDirectoryItem(handle=sPluginHandle,url=sUrl,listitem=item,isFolder=False)
        #xbmcplugin.endOfDirectory(sPluginHandle, True, False, False)
        #return r

        VSlog('Closing player')
        return self.theEnd