def addFromTab(self, params, tab, path, category='', need_resolve=0):
     table = []
     if category == 'iso':
         table = self.getMountsTable(True)
         
     tab.sort()
     for item in tab:
         params = dict(params)
         params.update( {'title':item['title'], 'category':category, 'desc':''} )
         if category in ['m3u', 'dir', 'iso']:
             fullPath = os_path.join(path, item['title'])
             params['path']  = fullPath
             if category != 'dir':
                 descTab = []
                 if item.get('size', -1) >= 0:
                     descTab.append( _("Total size: ") + formatBytes(item['size']) )
                     
                 #if len(table):
                 #    params['iso_mount_path']  = self.getMountPoint(fullPath, table)
                 #    if params['iso_mount_path']:
                 #        descTab.append( _('Mounted on %s') % params['iso_mount_path'] )
                 
                 if len(descTab):
                     params['desc'] = '[/br]'.join(descTab)
             self.addDir(params)
         else:
             fullPath = 'file://' + os_path.join(path, item['title'])
             params['url']  = fullPath
             params['type'] = category
             if 'picture' == category:
                 params['icon'] = fullPath
             params['need_resolve'] = need_resolve
             if item.get('size', -1) >= 0:
                 params['desc'] = _("Total size: ") + formatBytes(item['size'])
             self.currList.append(params)
Exemplo n.º 2
0
    def buildEntry(self, item):
        width = self.l.getItemSize().width()
        height = self.l.getItemSize().height()
        res = [None]

        # Downloaded Size
        info1 = formatBytes(item.downloadedSize)

        # File Size
        if item.fileSize > 0: info1 += "/" + formatBytes(item.fileSize)

        # Downloaded Procent
        if item.downloadedProcent >= 0:
            info1 += ", " + str(item.downloadedProcent) + "%"

        # Download Speed
        info2 = info1 + ", " + formatBytes(item.downloadedSpeed) + "/s"

        try:
            fileName = item.fileName.split('/')[-1]
        except:
            fileName = ''
        res.append(
            (eListboxPythonMultiContent.TYPE_TEXT, 70, 0, width - 70,
             self.fonts[0][2], 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, fileName))
        res.append((eListboxPythonMultiContent.TYPE_TEXT, 70, self.fonts[0][2],
                    width - 70, self.fonts[1][2], 1,
                    RT_HALIGN_LEFT | RT_VALIGN_CENTER, item.url))

        status = ""
        info = ""
        if DMHelper.STS.WAITING == item.status:
            status += _("PENDING")
        elif DMHelper.STS.DOWNLOADING == item.status:
            status += _("DOWNLOADING")
            info = info2
        elif DMHelper.STS.DOWNLOADED == item.status:
            status += _("DOWNLOADED")
            info = info1
        elif DMHelper.STS.INTERRUPTED == item.status:
            status += _("ABORTED")
            info = info1
        elif DMHelper.STS.ERROR == item.status:
            status += _("DOWNLOAD ERROR")

        res.append((eListboxPythonMultiContent.TYPE_TEXT, width - 240,
                    self.fonts[0][2] + self.fonts[1][2], 240, self.fonts[2][2],
                    2, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, status))
        res.append(
            (eListboxPythonMultiContent.TYPE_TEXT, 45,
             self.fonts[0][2] + self.fonts[1][2], width - 45 - 240,
             self.fonts[2][2], 2, RT_HALIGN_LEFT | RT_VALIGN_CENTER, info))

        res.append(
            (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 3, 1, 64, 64,
             self.dictPIX.get(item.status, None)))

        return res
Exemplo n.º 3
0
    def updateDisplay(self):
        printDBG("updateDisplay")
        if self.inMoviePlayer:
            printDBG("updateDisplay aborted - we are in moviePlayer")
            return

        if not self.mainTimerEnabled:
            printDBG("updateDisplay aborted - timer stoped")
            return

        self.downloader.updateStatistic()
        tmpBuffSize = self.downloader.getLocalFileSize() - self.lastSize + 1 # simple when getLocalFileSize() returns -1
        # remote size
        rFileSize = self.downloader.getRemoteFileSize()       
        if -1 == rFileSize: rFileSize = '??'
        else: rFileSize = formatBytes(float(rFileSize))
        # local size
        lFileSize = self.downloader.getLocalFileSize()
        if -1 == lFileSize: lFileSize = '??'
        else: lFileSize = formatBytes(float(lFileSize))
        # download speed
        dSpeed = self.downloader.getDownloadSpeed()
        if -1 == dSpeed: dSpeed = ''
        else: dSpeed = formatBytes(float(dSpeed))

        speed     = self.downloader.getDownloadSpeed()
        tmpStr    = ''
        if 0 < self.downloader.getLocalFileSize():
            if 0 <= self.downloader.getRemoteFileSize():
                tmpStr = "\n%s/%s" % (lFileSize, rFileSize)
            else:
                tmpStr = "\n%s" % (lFileSize)
            if 0 <= dSpeed:
               tmpStr += "\n%s/s" % (dSpeed)
        else:
            tmpStr += '\n\n'
        
        self["console"].setText(self.movieTitle + tmpStr)
        if tmpBuffSize > self.requestedBuffSize: percentage = 100
        else: percentage = (100 * tmpBuffSize) / self.requestedBuffSize
        self["percentage"].setText(str(percentage))
        self["icon"].nextFrame()
        
        # check if we start move player
        if self.canRunMoviePlayer:
            if tmpBuffSize >= self.requestedBuffSize or (self.downloader.getStatus() == DMHelper.STS.DOWNLOADED and 0 < self.downloader.getLocalFileSize()):
                self.runMovePlayer()
                return
        
        # check if it is downloading 
        if self.downloader.getStatus() not in [DMHelper.STS.DOWNLOADING, DMHelper.STS.WAITING]:
            self.session.openWithCallback(self.close, MessageBox, "Nastąpił błąd pobierania. \nStatus[%s], tmpBuffSize[%r], canRunMoviePlayer[%r]" % (self.downloader.getStatus(), tmpBuffSize, self.canRunMoviePlayer), type = MessageBox.TYPE_ERROR, timeout = 10 )
            self.canRunMoviePlayer = False
            # stop timer before message
            self.setMainTimerSts(False)

        return
Exemplo n.º 4
0
 def checkForFreeSpace(self, dir, requairedSpace):
     sts = True
     msg = ''
     if not FreeSpace(dir, requairedSpace, 1):
         sts = False
         msg = _(
             "There is no space in the directory [%s]\n Available[%s], required [%s]."
         ) % (dir, formatBytes(FreeSpace(dir, None,
                                         1)), formatBytes(requairedSpace))
     return sts, msg
Exemplo n.º 5
0
 def runMovePlayer(self):
     # this shoudl not happen but to make sure
     if not self.canRunMoviePlayer:
         printDBG('called runMovePlayer with canRunMoviePlayer set to False')
         return
     
     self.inMoviePlayer = True
     buffSize = self.downloader.getLocalFileSize() - self.lastSize 
     printDBG("Run MoviePlayer with buffer size [%s]" % formatBytes(float(buffSize)) )
     self.setMainTimerSts(False)
     
     player = self.activMoviePlayer
     printDBG('E2iPlayerBufferingWidget.runMovePlayer [%r]' % player)
     playerAdditionalParams = dict(self.playerAdditionalParams)
     playerAdditionalParams['downloader'] = self.downloader
     if self.isMOOVAtomAtTheBeginning:
         playerAdditionalParams['moov_atom_info'] = {'offset':0, 'size':self.moovAtomOffset + self.moovAtomSize, 'file':''}
     elif self.moovAtomStatus == self.MOOV_STS.DOWNLOADED and \
          DMHelper.STS.DOWNLOADED != self.downloader.getStatus(): 
         playerAdditionalParams['moov_atom_info'] = {'offset':self.moovAtomOffset, 'size': self.moovAtomSize, 'file':self.moovAtomPath}
     
     if strwithmeta(self.url).meta.get('iptv_proto', '') in ['f4m', 'uds', 'm3u8']:
         playerAdditionalParams['file-download-timeout'] = 90000 # 90s
     else:
         playerAdditionalParams['file-download-timeout'] = 10000 # 10s
     playerAdditionalParams['file-download-live'] = self._isInLiveMode()
     playerAdditionalParams['download_manager_available'] = self.downloadManager != None
     if "mini" == player: self.session.openWithCallback(self.leaveMoviePlayer, IPTVMiniMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 4)
     elif "exteplayer" == player: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'eplayer', playerAdditionalParams)
     elif "extgstplayer" == player: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'gstplayer', playerAdditionalParams)
     else: self.session.openWithCallback(self.leaveMoviePlayer, IPTVStandardMoviePlayer, self.filePath, self.movieTitle)
     playerAdditionalParams = None
Exemplo n.º 6
0
 def runMovePlayer(self):
     # this shoudl not happen but to make sure
     if not self.canRunMoviePlayer:
         printDBG('called runMovePlayer with canRunMoviePlayer set to False')
         return
     
     self.inMoviePlayer = True
     buffSize = self.downloader.getLocalFileSize() - self.lastSize 
     printDBG("Run MoviePlayer with buffer size [%s]" % formatBytes(float(buffSize)) )
     self.setMainTimerSts(False)
     
     exteplayerBlocked =  strwithmeta(self.url).meta.get('iptv_block_exteplayer', False)
     printDBG("runMovePlayer >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> exteplayerBlocked[%s]" % exteplayerBlocked)
     
     player = self.activMoviePlayer
     printDBG('IPTVPlayerBufferingWidget.runMovePlayer [%r]' % player)
     playerAdditionalParams = dict(self.playerAdditionalParams)
     playerAdditionalParams['downloader'] = self.downloader
     if strwithmeta(self.url).meta.get('iptv_proto', '') in ['f4m', 'uds', 'm3u8']:
         playerAdditionalParams['file-download-timeout'] = 90000 # 90s
     else:
         playerAdditionalParams['file-download-timeout'] = 10000 # 10s
     playerAdditionalParams['file-download-live'] = self._isInLiveMode()
     if "mini" == player:
         self.session.openWithCallback(self.leaveMoviePlayer, IPTVMiniMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 4)
     elif "exteplayer" == player:
         if not exteplayerBlocked: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'eplayer', playerAdditionalParams)
         else: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'gstplayer', playerAdditionalParams)
     elif "extgstplayer" == player: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'gstplayer', playerAdditionalParams)
     else: self.session.openWithCallback(self.leaveMoviePlayer, IPTVStandardMoviePlayer, self.filePath, self.movieTitle)
     playerAdditionalParams = None
Exemplo n.º 7
0
    def getLinksForVideo(self, cItem):
        urlsTab = []

        if 'url' in cItem and cItem['url'].startswith('rtmp://'):
            urlsTab = [{'name': 'rtmp', 'url': cItem['url'], 'need_resolve':0}]
        elif 'url' in cItem:
            urlsTab = getDirectM3U8Playlist(cItem['url'])
        else:
            url = 'http://mediaserwer3.christusvincit-tv.pl/api_v3/index.php?service=multirequest&apiVersion=3.1&expiry=86400&clientTag=kwidget%3Av2.41&format=1&ignoreNull=1&action=null&1:service=session&1:action=startWidgetSession&1:widgetId=_100&2:ks=%7B1%3Aresult%3Aks%7D&2:service=baseentry&2:action=list&2:filter:objectType=KalturaBaseEntryFilter&2:filter:redirectFromEntryId='
            url += cItem['f_id']
            url += '&3:ks=%7B1%3Aresult%3Aks%7D&3:contextDataParams:referrer=http%3A%2F%2Fmediaserwer3.christusvincit-tv.pl&3:contextDataParams:objectType=KalturaEntryContextDataParams&3:contextDataParams:flavorTags=all&3:contextDataParams:streamerType=auto&3:service=baseentry&3:entryId=%7B2%3Aresult%3Aobjects%3A0%3Aid%7D&3:action=getContextData&4:ks=%7B1%3Aresult%3Aks%7D&4:service=metadata_metadata&4:action=list&4:version=-1&4:filter:metadataObjectTypeEqual=1&4:filter:orderBy=%2BcreatedAt&4:filter:objectIdEqual=%7B2%3Aresult%3Aobjects%3A0%3Aid%7D&4:pager:pageSize=1&5:ks=%7B1%3Aresult%3Aks%7D&5:service=cuepoint_cuepoint&5:action=list&5:filter:objectType=KalturaCuePointFilter&5:filter:orderBy=%2BstartTime&5:filter:statusEqual=1&5:filter:entryIdEqual=%7B2%3Aresult%3Aobjects%3A0%3Aid%7D&kalsig=404d9c08e114ce91328cd739e5151b80'
            sts, data = self.getPage(url)
            if not sts:
                return []

            try:
                data = json_loads(data)
                baseUrl = data[1]['objects'][0]['dataUrl']
                for item in data[2]['flavorAssets']:
                    if item['fileExt'] != 'mp4' or not item['isWeb']:
                        continue
                    item['bitrate'] *= 1024
                    name = '%sx%s %s, bitrate: %s' % (item['width'], item['height'], formatBytes(item['size'] * 1024), item['bitrate'])
                    url = baseUrl.replace('/format/', '/flavorId/%s/format/' % item['id'])
                    urlsTab.append({'name': name, 'url': url, 'need_resolve': 0, 'bitrate': item['bitrate'], 'original': item['isOriginal']})
                urlsTab.sort(key=lambda x: x['bitrate'], reverse=True)
            except Exception:
                printExc()
        if len(urlsTab):
            max_bitrate = int(config.plugins.iptvplayer.christusvincit_preferred_bitrate.value)
            urlsTab = CSelOneLink(urlsTab, lambda x: int(x['bitrate']), max_bitrate).getSortedLinks()
            if config.plugins.iptvplayer.christusvincit_use_preferred_bitrate.value:
                urlsTab = [urlsTab[0]]
        return urlsTab
Exemplo n.º 8
0
    def addFromTab(self, params, tab, path, category='', need_resolve=0):
        table = []
        if category == 'iso':
            table = self.getMountsTable(True)

        if config.plugins.iptvplayer.local_alphasort.value == 'alphabetically':
            try:
                tab.sort(key=lambda item: item['title'])
            except Exception:
                printExc()
        for item in tab:
            params = dict(params)
            params.update({
                'good_for_fav': params.get('next_good_for_fav', True),
                'title': item['title'],
                'category': category,
                'desc': ''
            })
            if category in ['m3u', 'dir', 'iso']:
                fullPath = os_path.join(path, item['raw_name'])
                params['path'] = fullPath
                if category != 'dir':
                    descTab = []
                    if item.get('size', -1) >= 0:
                        descTab.append(
                            _("Total size: ") + formatBytes(item['size']))

                    #if len(table):
                    #    params['iso_mount_path']  = self.getMountPoint(fullPath, table)
                    #    if params['iso_mount_path']:
                    #        descTab.append( _('Mounted on %s') % params['iso_mount_path'] )

                    if len(descTab):
                        params['desc'] = '[/br]'.join(descTab)
                self.addDir(params)
            else:
                fullPath = 'file://' + os_path.join(path, item['raw_name'])
                params['url'] = fullPath
                params['type'] = category
                if 'picture' == category:
                    params['icon'] = fullPath
                params['need_resolve'] = need_resolve
                if item.get('size', -1) >= 0:
                    params['desc'] = _("Total size: ") + formatBytes(
                        item['size'])
                self.currList.append(params)
Exemplo n.º 9
0
    def runMovePlayer(self):
        # this shoudl not happen but to make sure
        if not self.canRunMoviePlayer:
            printDBG(
                'called runMovePlayer with canRunMoviePlayer set to False')
            return

        self.inMoviePlayer = True
        buffSize = self.downloader.getLocalFileSize() - self.lastSize
        printDBG("Run MoviePlayer with buffer size [%s]" %
                 formatBytes(float(buffSize)))
        self.setMainTimerSts(False)

        exteplayerBlocked = strwithmeta(self.url).meta.get(
            'iptv_block_exteplayer', False)
        printDBG(
            "runMovePlayer >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> exteplayerBlocked[%s]"
            % exteplayerBlocked)

        player = self.activMoviePlayer
        printDBG('IPTVPlayerBufferingWidget.runMovePlayer [%r]' % player)
        playerAdditionalParams = dict(self.playerAdditionalParams)
        playerAdditionalParams['downloader'] = self.downloader
        if strwithmeta(self.url).meta.get('iptv_proto',
                                          '') in ['f4m', 'uds', 'm3u8']:
            playerAdditionalParams['file-download-timeout'] = 90000  # 90s
        else:
            playerAdditionalParams['file-download-timeout'] = 10000  # 10s
        playerAdditionalParams['file-download-live'] = self._isInLiveMode()
        if "mini" == player:
            self.session.openWithCallback(self.leaveMoviePlayer,
                                          IPTVMiniMoviePlayer, self.filePath,
                                          self.movieTitle, self.lastPosition,
                                          4)
        elif "exteplayer" == player:
            if not exteplayerBlocked:
                self.session.openWithCallback(self.leaveMoviePlayer,
                                              IPTVExtMoviePlayer,
                                              self.filePath, self.movieTitle,
                                              self.lastPosition, 'eplayer',
                                              playerAdditionalParams)
            else:
                self.session.openWithCallback(self.leaveMoviePlayer,
                                              IPTVExtMoviePlayer,
                                              self.filePath, self.movieTitle,
                                              self.lastPosition, 'gstplayer',
                                              playerAdditionalParams)
        elif "extgstplayer" == player:
            self.session.openWithCallback(self.leaveMoviePlayer,
                                          IPTVExtMoviePlayer, self.filePath,
                                          self.movieTitle, self.lastPosition,
                                          'gstplayer', playerAdditionalParams)
        else:
            self.session.openWithCallback(self.leaveMoviePlayer,
                                          IPTVStandardMoviePlayer,
                                          self.filePath, self.movieTitle)
        playerAdditionalParams = None
Exemplo n.º 10
0
 def listsMainMenu(self):
     printDBG("Chomikuj.listsMainMenu")
     data    = self.loginData['AccountBalance']
     quota   = formatBytes(1024 * (self._getJItemNum(data, 'QuotaAdditional', 0) + self._getJItemNum(data, 'QuotaLeft', 0)))
     account = self._getJItemStr(self.loginData, 'AccountName', '')
     title   = 'Chomik "%s" (%s transferu)' % (account, quota)
     self.addDir({'name':'category', 'title':title,                       'category':'account'})
     self.addDir({'name':'category', 'title':'Wyszukaj',                  'category':'search', 'search_item':True})
     self.addDir({'name':'category', 'title':'Historia wyszukiwania',     'category':'search_history'})
Exemplo n.º 11
0
    def buildEntry(self, item):
        width  = self.l.getItemSize().width()
        height = self.l.getItemSize().height()
        res = [ None ]
        
        # Downloaded Size
        info1 = formatBytes(item.downloadedSize)
        
        # File Size
        if item.fileSize > 0: info1 += "/" + formatBytes(item.fileSize)

        # Downloaded Procent
        if item.downloadedProcent >= 0: info1 += ", " + str(item.downloadedProcent) + "%"
 
        # Download Speed
        info2 = info1 + ", " + formatBytes(item.downloadedSpeed) + "/s"
        
        try: fileName = item.fileName.split('/')[-1]
        except: fileName = ''
        res.append((eListboxPythonMultiContent.TYPE_TEXT, 70, 0, width-70, self.fonts[0][2], 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, fileName))
        res.append((eListboxPythonMultiContent.TYPE_TEXT, 70, self.fonts[0][2], width-70, self.fonts[1][2], 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, item.url))
        
        status = ""
        info = ""
        if DMHelper.STS.WAITING == item.status:
            status += _("PENDING")
        elif DMHelper.STS.DOWNLOADING == item.status:
            status += _("DOWNLOADING")
            info = info2
        elif DMHelper.STS.DOWNLOADED == item.status:
            status += _("DOWNLOADED")
            info = info1
        elif DMHelper.STS.INTERRUPTED == item.status:
            status += _("ABORTED")
            info = info1
        elif DMHelper.STS.ERROR == item.status:
            status += _("DOWNLOAD ERROR")
            
        res.append((eListboxPythonMultiContent.TYPE_TEXT, width - 240, self.fonts[0][2]+self.fonts[1][2], 240, self.fonts[2][2], 2, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, status))
        res.append((eListboxPythonMultiContent.TYPE_TEXT, 45, self.fonts[0][2]+self.fonts[1][2], width - 45 - 240, self.fonts[2][2], 2, RT_HALIGN_LEFT|RT_VALIGN_CENTER, info))
        
        res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 3, 1, 64, 64, self.dictPIX.get(item.status, None)))
         
        return res
Exemplo n.º 12
0
    def handleDataRequest(self, cItem, url):
        sts, data = self.requestJsonData(url)
        if sts:
            if 0 == self._getJItemNum(data, "Code", -1):
                # list folders
                for item in data.get("Folders", []):
                    params = dict(cItem)
                    params.update(
                        {
                            "title": self._getJItemStr(item, "Name", ""),
                            "page": 1,
                            "parent": self._getJItemNum(item, "Id", 0),
                        }
                    )
                    self.addDir(params)

                # list files
                if "Files" in data:
                    key = "Files"
                else:
                    key = "Results"
                for item in data.get(key, []):
                    params = dict(cItem)
                    title = self._getJItemStr(item, "FileName", "")
                    size = formatBytes(1024 * self._getJItemNum(item, "Size", 0))
                    desc = "%s, %s, %s" % (
                        size,
                        self._getJItemStr(item, "MediaType", ""),
                        self._getJItemStr(item, "FileType", ""),
                    )
                    mediaType = self._getJItemStr(item, "MediaType", "")
                    params.update(
                        {
                            "title": title,
                            "file_id": self._getJItemNum(item, "FileId", -1),
                            "icon": self._getJItemStr(item, "SmallThumbnailImg", ""),
                            "desc": desc,
                            "size": size,
                            "page": 1,
                        }
                    )
                    if mediaType in ["Music", "Video"]:
                        params.update({"url": self._getJItemStr(item, "StreamingUrl", "")})
                        self.addVideo(params)
                    elif "Image" == mediaType:
                        params.update({"url": self._getJItemStr(item, "ThumbnailImg", "")})
                        self.addPicture(params)
                    else:
                        printDBG("Chomikuj list file: unknown mediaType [%s]" % mediaType)

                if data.get("IsNextPageAvailable", False):
                    params = dict(cItem)
                    params.update({"title": "Następna strona", "page": cItem.get("page", 1) + 1})
                    self.addDir(params)
Exemplo n.º 13
0
 def listsMainMenu(self):
     printDBG("Chomikuj.listsMainMenu")
     data = self.loginData["AccountBalance"]
     quota = formatBytes(
         1024 * (self._getJItemNum(data, "QuotaAdditional", 0) + self._getJItemNum(data, "QuotaLeft", 0))
     )
     account = self._getJItemStr(self.loginData, "AccountName", "")
     title = 'Chomik "%s" (%s transferu)' % (account, quota)
     self.addDir({"name": "category", "title": title, "category": "account"})
     self.addDir({"name": "category", "title": "Wyszukaj", "category": "Wyszukaj"})
     self.addDir({"name": "category", "title": "Historia wyszukiwania", "category": "Historia wyszukiwania"})
Exemplo n.º 14
0
 def handleDataRequest(self, cItem, url):
     sts, data = self.requestJsonData(url)
     if sts:
         printDBG(byteify(data))
         if 0 == self._getJItemNum(data, 'Code', -1):
             # Parent Folder
             if 'ParentId' in data and 'ParentName' in data and len(self._getJItemStr(data, 'ParentName')) and 'Owner' in data and 'Id' in data['Owner']:
                 if cItem.get('prev_parent', None) != self._getJItemNum(data, 'ParentId'):
                     params = dict(cItem)
                     params.update({'good_for_fav': True, 'category':'foreign_folder', 'title':'\xe2\x86\x91 ' + self._getJItemStr(data, 'ParentName'), 'prev_parent':cItem.get('parent', None), 'parent':self._getJItemNum(data, 'ParentId'), 'owner':self._getJItemNum(data['Owner'], 'Id')})
                     self.addDir(params)
             
             # list folders
             for item in data.get('Folders', []):
                 params = dict(cItem)
                 params.update({'good_for_fav': True, 'title':self._getJItemStr(item, 'Name', ''), 'page': 1, 'prev_parent':cItem.get('parent', None), 'parent':self._getJItemNum(item, 'Id', 0)})
                 self.addDir(params)
             
             # list files
             if 'Files' in data:
                 key = 'Files'
             else:
                 key = 'Results'
             for item in data.get(key, []):
                 params = dict(cItem)
                 title = self._getJItemStr(item, 'FileName', '') 
                 size = formatBytes(1024 * self._getJItemNum(item, 'Size', 0))
                 desc = '%s, %s, %s' % (size, self._getJItemStr(item, 'MediaType', ''), self._getJItemStr(item, 'FileType', ''))
                 if item.get('IsFileFreeForUser', False):
                     desc = 'Darmowy[/br]'+desc
                 params.update({'title'  : title,
                                'file_id': self._getJItemNum(item, 'FileId', -1),
                                'icon'   : self._getJItemStr(item, 'SmallThumbnailImg', ''),
                                'desc'   : desc,
                                'size'   : size,
                                'is_free': item.get('IsFileFreeForUser', False),
                                'page'   : 1 })
                 
                 if 'FolderId' in item and 'Owner' in item and 'Id' in item['Owner'] and 'Name' in item['Owner']:
                     params.update({'category':'explore_item', 'raw_item':dict(item)})
                     self.addDir(params)
                 else:
                     self._addItem(item, params)
             
             if data.get('IsNextPageAvailable', False):
                 params = dict(cItem)
                 params.update({'title':'Następna strona', 'page': cItem.get('page', 1) + 1})
                 self.addDir(params)
 def runMovePlayer(self):
     # this shoudl not happen but to make sure
     if not self.canRunMoviePlayer:
         printDBG('called runMovePlayer with canRunMoviePlayer set to False')
         return
     
     self.inMoviePlayer = True
     buffSize = self.downloader.getLocalFileSize() - self.lastSize 
     printDBG("Run MoviePlayer with buffer size [%s]" % formatBytes(float(buffSize)) )
     self.setMainTimerSts(False)
     
     exteplayerBlocked =  strwithmeta(self.url).meta.get('iptv_block_exteplayer', False)
     printDBG("runMovePlayer >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> exteplayerBlocked[%s]" % exteplayerBlocked)
     
     player = self.activMoviePlayer
     printDBG('IPTVPlayerBufferingWidget.runMovePlayer [%r]' % player)
     if "mini" == player:
         self.session.openWithCallback(self.leaveMoviePlayer, IPTVMiniMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 4)
     elif "exteplayer" == player:
         if not exteplayerBlocked: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'eplayer', {'downloader':self.downloader})
         else: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'gstplayer', {'downloader':self.downloader})
     elif "extgstplayer" == player: self.session.openWithCallback(self.leaveMoviePlayer, IPTVExtMoviePlayer, self.filePath, self.movieTitle, self.lastPosition, 'gstplayer', {'downloader':self.downloader})
     else: self.session.openWithCallback(self.leaveMoviePlayer, IPTVStandardMoviePlayer, self.filePath, self.movieTitle)
Exemplo n.º 16
0
    def updateDisplay(self):
        printDBG("updateDisplay")
        if self.inMoviePlayer:
            printDBG("updateDisplay aborted - we are in moviePlayer")
            return

        if not self.mainTimerEnabled:
            printDBG("updateDisplay aborted - timer stoped")
            return

        self.downloader.updateStatistic()
        tmpBuffSize = self.downloader.getLocalFileSize() - self.lastSize + 1 # simple when getLocalFileSize() returns -1
        
        if None != self.downloader and self.downloader.getName() == "wget m3u8" \
           and self.downloader.getTotalFileDuration() > 0:
            totalDuration = self.downloader.getTotalFileDuration()
            downloadDuration = self.downloader.getDownloadedFileDuration()
            rFileSize = str(timedelta(seconds=totalDuration))
            lFileSize = str(timedelta(seconds=downloadDuration))
            if rFileSize.startswith('0:'):
                rFileSize = rFileSize[2:]
            if lFileSize.startswith('0:'):
                lFileSize = lFileSize[2:]
        else:
            # remote size
            rFileSize = self.downloader.getRemoteFileSize()       
            if -1 == rFileSize: rFileSize = '??'
            else: rFileSize = formatBytes(float(rFileSize))
            # local size
            lFileSize = self.downloader.getLocalFileSize()
            if -1 == lFileSize: lFileSize = '??'
            else: lFileSize = formatBytes(float(lFileSize))
        
        
        # download speed
        dSpeed = self.downloader.getDownloadSpeed()
        if dSpeed > -1 and self.downloader.getLocalFileSize() > 0:
            dSpeed = formatBytes(float(dSpeed))
        else:
            dSpeed = ''
        
        speed     = self.downloader.getDownloadSpeed()
        tmpStr    = ''
        if '??' != lFileSize:
            if '??' != rFileSize:
                tmpStr = "\n%s/%s" % (lFileSize, rFileSize)
            else:
                tmpStr = "\n%s" % (lFileSize)
            if '' != dSpeed:
               tmpStr += "\n%s/s" % (dSpeed)
        else:
            tmpStr += '\n\n'
        
        self["console"].setText(self.movieTitle + tmpStr)
        
        percentage = 0
        requestedBuffSize = -1
        if self.downloader.getPlayableFileSize() > 0:
            requestedBuffSize = self.requestedBuffSize
            if tmpBuffSize > requestedBuffSize: percentage = 100
            else: percentage = (100 * tmpBuffSize) / requestedBuffSize
        elif self.downloader.getLocalFileSize() > 0 and self.downloader.getRemoteFileSize() > 0:
            localSize  = self.downloader.getLocalFileSize()
            remoteSize = self.downloader.getRemoteFileSize()
            if localSize > remoteSize: percentage = 100
            else: percentage = (100 * localSize) / remoteSize
            
        self["percentage"].setText(str(percentage))
        self["icon"].nextFrame()
        
        # check if we start move player
        if self.canRunMoviePlayer and requestedBuffSize > -1:
            if tmpBuffSize >= requestedBuffSize or (self.downloader.getStatus() == DMHelper.STS.DOWNLOADED and 0 < self.downloader.getLocalFileSize()):
                self.runMovePlayer()
                return
        
        # check if it is downloading 
        if self.downloader.getStatus() not in [DMHelper.STS.POSTPROCESSING, DMHelper.STS.DOWNLOADING, DMHelper.STS.WAITING]:
            self.session.openWithCallback(self.close, MessageBox, _("Error occurs during download. \nStatus[%s], tmpBuffSize[%r], canRunMoviePlayer[%r]") % (self.downloader.getStatus(), tmpBuffSize, self.canRunMoviePlayer), type = MessageBox.TYPE_ERROR, timeout = 10 )
            self.canRunMoviePlayer = False
            # stop timer before message
            self.setMainTimerSts(False)

        return
Exemplo n.º 17
0
    def handleDataRequest(self, cItem, url):
        sts, data = self.requestJsonData(url)
        if sts:
            if 0 == self._getJItemNum(data, 'Code', -1):
                # list folders
                for item in data.get('Folders', []):
                    params = dict(cItem)
                    params.update({
                        'title': self._getJItemStr(item, 'Name', ''),
                        'page': 1,
                        'parent': self._getJItemNum(item, 'Id', 0)
                    })
                    self.addDir(params)

                # list files
                if 'Files' in data:
                    key = 'Files'
                else:
                    key = 'Results'
                for item in data.get(key, []):
                    params = dict(cItem)
                    title = self._getJItemStr(item, 'FileName', '')
                    size = formatBytes(1024 *
                                       self._getJItemNum(item, 'Size', 0))
                    desc = '%s, %s, %s' % (
                        size, self._getJItemStr(item, 'MediaType', ''),
                        self._getJItemStr(item, 'FileType', ''))
                    mediaType = self._getJItemStr(item, 'MediaType', '')
                    params.update({
                        'title':
                        title,
                        'file_id':
                        self._getJItemNum(item, 'FileId', -1),
                        'icon':
                        self._getJItemStr(item, 'SmallThumbnailImg', ''),
                        'desc':
                        desc,
                        'size':
                        size,
                        'page':
                        1
                    })
                    if mediaType in ['Music', 'Video']:
                        params.update({
                            'url':
                            self._getJItemStr(item, 'StreamingUrl', '')
                        })
                        self.addVideo(params)
                    elif 'Image' == mediaType:
                        params.update({
                            'url':
                            self._getJItemStr(item, 'ThumbnailImg', '')
                        })
                        self.addPicture(params)
                    else:
                        printDBG('Chomikuj list file: unknown mediaType [%s]' %
                                 mediaType)

                if data.get('IsNextPageAvailable', False):
                    params = dict(cItem)
                    params.update({
                        'title': 'Następna strona',
                        'page': cItem.get('page', 1) + 1
                    })
                    self.addDir(params)
Exemplo n.º 18
0
    def updateDisplay(self):
        printDBG("updateDisplay")
        if self.inMoviePlayer:
            printDBG("updateDisplay aborted - we are in moviePlayer")
            return

        if not self.mainTimerEnabled:
            printDBG("updateDisplay aborted - timer stoped")
            return

        self.downloader.updateStatistic()
        tmpBuffSize = self.downloader.getLocalFileSize(
        ) - self.lastSize + 1  # simple when getLocalFileSize() returns -1

        if None != self.downloader and "m3u8" in self.downloader.getName() \
           and self.downloader.getTotalFileDuration() > 0:
            totalDuration = self.downloader.getTotalFileDuration()
            downloadDuration = self.downloader.getDownloadedFileDuration()
            rFileSize = str(timedelta(seconds=totalDuration))
            lFileSize = str(timedelta(seconds=downloadDuration))
            if rFileSize.startswith('0:'):
                rFileSize = rFileSize[2:]
            if lFileSize.startswith('0:'):
                lFileSize = lFileSize[2:]
        else:
            # remote size
            rFileSize = self.downloader.getRemoteFileSize()
            if -1 == rFileSize: rFileSize = '??'
            else: rFileSize = formatBytes(float(rFileSize))
            # local size
            lFileSize = self.downloader.getLocalFileSize()
            if -1 == lFileSize: lFileSize = '??'
            else: lFileSize = formatBytes(float(lFileSize))

        # download speed
        dSpeed = self.downloader.getDownloadSpeed()
        if dSpeed > -1 and self.downloader.getLocalFileSize() > 0:
            dSpeed = formatBytes(float(dSpeed))
        else:
            dSpeed = ''

        speed = self.downloader.getDownloadSpeed()
        tmpStr = ''
        if '??' != lFileSize:
            if '??' != rFileSize:
                tmpStr = "\n%s/%s" % (lFileSize, rFileSize)
            else:
                tmpStr = "\n%s" % (lFileSize)
            if '' != dSpeed:
                tmpStr += "\n%s/s" % (dSpeed)
        else:
            tmpStr += '\n\n'

        self["console"].setText(self.movieTitle + tmpStr)

        percentage = 0
        requestedBuffSize = -1
        if self.downloader.getPlayableFileSize() > 0:
            requestedBuffSize = self.requestedBuffSize
            if tmpBuffSize > requestedBuffSize: percentage = 100
            else: percentage = (100 * tmpBuffSize) / requestedBuffSize
        elif self.downloader.getLocalFileSize(
        ) > 0 and self.downloader.getRemoteFileSize() > 0:
            localSize = self.downloader.getLocalFileSize()
            remoteSize = self.downloader.getRemoteFileSize()
            if localSize > remoteSize: percentage = 100
            else: percentage = (100 * localSize) / remoteSize

        self["percentage"].setText(str(percentage))
        self["icon"].nextFrame()

        # check if we start move player
        if self.canRunMoviePlayer and requestedBuffSize > -1:
            if tmpBuffSize >= requestedBuffSize or (
                    self.downloader.getStatus() == DMHelper.STS.DOWNLOADED
                    and 0 < self.downloader.getLocalFileSize()):
                self.runMovePlayer()
                return

        # check if it is downloading
        if self.downloader.getStatus() not in [
                DMHelper.STS.POSTPROCESSING, DMHelper.STS.DOWNLOADING,
                DMHelper.STS.WAITING
        ]:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _("Error occurs during download. \nStatus[%s], tmpBuffSize[%r], canRunMoviePlayer[%r]"
                  ) % (self.downloader.getStatus(), tmpBuffSize,
                       self.canRunMoviePlayer),
                type=MessageBox.TYPE_ERROR,
                timeout=10)
            self.canRunMoviePlayer = False
            # stop timer before message
            self.setMainTimerSts(False)

        return
 def checkForFreeSpace(self, dir, requairedSpace):
     sts = True
     msg = ''
     if not FreeSpace(dir, requairedSpace, 1):
         sts = False
         msg = _("There is no space in the directory [%s]\n Available[%s], required [%s].") % (dir, formatBytes(FreeSpace(dir, None, 1)), formatBytes(requairedSpace))
     return sts, msg
Exemplo n.º 20
0
    def updateDisplay(self):
        printDBG("updateDisplay")
        if self.inMoviePlayer:
            printDBG("updateDisplay aborted - we are in moviePlayer")
            return

        self.updateRecButton()

        if not self.mainTimerEnabled:
            printDBG("updateDisplay aborted - timer stoped")
            return

        self.downloader.updateStatistic()
        localSize = self.downloader.getLocalFileSize()
        remoteSize = self.downloader.getRemoteFileSize()

        if self.checkMOOVAtom and \
           localSize > 10240:
            self.checkMOOVAtom = False

            if remoteSize > self.maxMOOVAtomSize and \
               self.downloader.getName() == "wget" and \
               (self.clouldBeMP4 or (None != self.downloader.getMimeType() and \
               'mp4' in self.downloader.getMimeType())):
                # check moov atom position
                # if it is located at the begining of MP4 file
                # it should be just after ftyp atom
                try:
                    f = open(self.filePath, "rb")
                    currOffset = 0
                    while currOffset < localSize:
                        rawSize = ReadUint32(f.read(4), False)
                        rawType = f.read(4)
                        printDBG(">> rawType [%s]" % rawType)
                        printDBG(">> rawSize [%d]" % rawSize)
                        if currOffset == 0 and rawType != "ftyp":
                            # this does not looks like MP4 file
                            break
                        else:
                            if rawType == "moov":
                                self.moovAtomOffset = currOffset
                                self.moovAtomSize = rawSize
                                self.isMOOVAtomAtTheBeginning = True
                                break
                            elif rawType == "mdat":
                                # we are not sure if after mdat will be moov atom but
                                # if this will be max last 10MB of file then
                                # we will download it
                                self.moovAtomOffset = currOffset + rawSize
                                self.moovAtomSize = remoteSize - self.moovAtomOffset
                                self.isMOOVAtomAtTheBeginning = False
                                break
                            currOffset += rawSize
                        f.seek(currOffset, 0)
                    printDBG(">> moovAtomOffset[%d]" % self.moovAtomOffset)
                    printDBG(">> moovAtomSize[%d]" % self.moovAtomSize)
                except Exception:
                    printExc()

        if None != self.downloader and self.downloader.hasDurationInfo() \
           and self.downloader.getTotalFileDuration() > 0:
            totalDuration = self.downloader.getTotalFileDuration()
            downloadDuration = self.downloader.getDownloadedFileDuration()
            rFileSize = str(timedelta(seconds=totalDuration))
            lFileSize = str(timedelta(seconds=downloadDuration))
            if rFileSize.startswith('0:'):
                rFileSize = rFileSize[2:]
            if lFileSize.startswith('0:'):
                lFileSize = lFileSize[2:]
        else:
            # remote size
            if -1 == remoteSize: rFileSize = '??'
            else: rFileSize = formatBytes(float(remoteSize))
            # local size
            if -1 == localSize: lFileSize = '??'
            else: lFileSize = formatBytes(float(localSize))

        # download speed
        dSpeed = self.downloader.getDownloadSpeed()
        if dSpeed > -1 and localSize > 0:
            dSpeed = formatBytes(float(dSpeed))
        else:
            dSpeed = ''

        speed = self.downloader.getDownloadSpeed()
        tmpStr = ''
        if '??' != lFileSize:
            if '??' != rFileSize:
                tmpStr = "\n%s/%s" % (lFileSize, rFileSize)
            else:
                tmpStr = "\n%s" % (lFileSize)
            if '' != dSpeed:
                tmpStr += "\n%s/s" % (dSpeed)
        else:
            tmpStr += '\n\n'

        self["console"].setText(self.movieTitle + tmpStr)

        handled = False
        percentage = 0
        requestedBuffSize = -1
        tmpBuffSize = 0
        if self.isMOOVAtomAtTheBeginning == True:
            moovAtomDataSize = self.moovAtomOffset + self.moovAtomSize
            if moovAtomDataSize > localSize:
                if self.moovAtomStatus != self.MOOV_STS.DOWNLOADING:
                    self["addinfo"].setText(
                        _("Please wait for initialization data."))
                    self.moovAtomStatus = self.MOOV_STS.DOWNLOADING
                remoteSize = self.moovAtomOffset + self.moovAtomSize
                if localSize > remoteSize: percentage = 100
                else: percentage = (100 * localSize) / remoteSize
            else:
                requestedBuffSize = self.requestedBuffSize
                if self.lastSize > moovAtomDataSize:
                    tmpBuffSize = localSize - self.lastSize
                else:
                    tmpBuffSize = localSize - moovAtomDataSize
                if tmpBuffSize > requestedBuffSize: percentage = 100
                else: percentage = (100 * tmpBuffSize) / requestedBuffSize
                if self.moovAtomStatus != self.MOOV_STS.DOWNLOADED:
                    self["addinfo"].setText("")
                    self.moovAtomStatus = self.MOOV_STS.DOWNLOADED
            handled = True
        elif self.isMOOVAtomAtTheBeginning == False and self.moovAtomStatus not in [
                self.MOOV_STS.WAITING, self.MOOV_STS.ERROR,
                self.MOOV_STS.DOWNLOADED
        ]:
            # At now only exteplayer3 is able to use moov atom in separate file
            if self.activMoviePlayer == 'exteplayer' and self.moovAtomStatus == self.MOOV_STS.UNKNOWN:
                url, downloaderParams = DMHelper.getDownloaderParamFromUrl(
                    self.url)
                downloaderParams['start_pos'] = self.moovAtomOffset
                self.moovAtomDownloader = DownloaderCreator(self.url)
                self.moovAtomDownloader.start(url, self.moovAtomPath,
                                              downloaderParams)
                self.moovAtomStatus = self.MOOV_STS.DOWNLOADING
                self["addinfo"].setText(
                    _("Please wait - downloading initialization data."))
            elif self.moovAtomStatus == self.MOOV_STS.DOWNLOADING:
                self.moovAtomDownloader.updateStatistic()
                status = self.moovAtomDownloader.getStatus()
                moovLocalSize = self.moovAtomDownloader.getLocalFileSize()
                moovRemoteSize = self.moovAtomDownloader.getRemoteFileSize()
                if status == DMHelper.STS.DOWNLOADING:
                    if moovLocalSize > 0 and self.moovAtomSize > 0:
                        if moovLocalSize > self.moovAtomSize: percentage = 100
                        else:
                            percentage = (100 *
                                          moovLocalSize) / self.moovAtomSize
                elif status == DMHelper.STS.DOWNLOADED or (
                        status == DMHelper.STS.INTERRUPTED
                        and moovLocalSize == self.moovAtomSize):
                    self.moovAtomStatus = self.MOOV_STS.DOWNLOADED
                    self["addinfo"].setText("")
                else:
                    self.moovAtomStatus = self.MOOV_STS.ERROR

            handled = True
            if self.moovAtomStatus in [
                    self.MOOV_STS.UNKNOWN, self.MOOV_STS.ERROR
            ]:
                printDBG(">> [%s] [%s]" %
                         (self.activMoviePlayer, self.moovAtomStatus))
                msg = [_("Whole file must be downloaded to start playback!")]
                if self.moovAtomStatus == self.MOOV_STS.UNKNOWN and self.activMoviePlayer != 'exteplayer':
                    msg.append(
                        _("You can use external eplayer to start playback faster."
                          ))
                self["addinfo"].setText('\n'.join(msg))
                self.moovAtomStatus = self.MOOV_STS.WAITING
                handled = False

        if not handled and self.moovAtomStatus != self.MOOV_STS.WAITING:
            tmpBuffSize = localSize - self.lastSize + 1  # simple when getLocalFileSize() returns -1
            if self.downloader.getPlayableFileSize() > 0:
                requestedBuffSize = self.requestedBuffSize
                if tmpBuffSize > requestedBuffSize: percentage = 100
                else: percentage = (100 * tmpBuffSize) / requestedBuffSize
                handled = True

        if not handled and localSize > 0 and remoteSize > 0:
            if localSize > remoteSize: percentage = 100
            else: percentage = (100 * localSize) / remoteSize

        self["percentage"].setText(str(percentage))
        self["icon"].nextFrame()

        # check if we start movie player
        if self.canRunMoviePlayer:
            if (requestedBuffSize > -1 and tmpBuffSize >= requestedBuffSize) or \
               (self.downloader.getStatus() == DMHelper.STS.DOWNLOADED and 0 < localSize):
                self.runMovePlayer()
                return

        # check if it is downloading
        if self.downloader.getStatus() not in [
                DMHelper.STS.POSTPROCESSING, DMHelper.STS.DOWNLOADING,
                DMHelper.STS.WAITING
        ]:
            #messageTab = [_("Error occurs during download. \nStatus[%s], tmpBuffSize[%r], canRunMoviePlayer[%r]") % (self.downloader.getStatus(), tmpBuffSize, self.canRunMoviePlayer)]
            messageTab = [_("Error occurs during download.")]
            errorCode, errorDesc = self.downloader.getLastError()
            if errorCode != None:
                messageTab.append(
                    _('%s returned %s: %s') %
                    (self.downloader.getName(), errorCode, _(errorDesc)))
            self.session.openWithCallback(self.iptvDoClose,
                                          MessageBox,
                                          '\n'.join(messageTab),
                                          type=MessageBox.TYPE_ERROR,
                                          timeout=10)
            self.canRunMoviePlayer = False
            # stop timer before message
            self.setMainTimerSts(False)

        self.updateOKButton()
        self.updateRecButton()
        return
Exemplo n.º 21
0
    def updateDisplay(self):
        printDBG("updateDisplay")
        if self.inMoviePlayer:
            printDBG("updateDisplay aborted - we are in moviePlayer")
            return

        if not self.mainTimerEnabled:
            printDBG("updateDisplay aborted - timer stoped")
            return

        self.downloader.updateStatistic()
        tmpBuffSize = self.downloader.getLocalFileSize(
        ) - self.lastSize + 1  # simple when getLocalFileSize() returns -1
        # remote size
        rFileSize = self.downloader.getRemoteFileSize()
        if -1 == rFileSize: rFileSize = '??'
        else: rFileSize = formatBytes(float(rFileSize))
        # local size
        lFileSize = self.downloader.getLocalFileSize()
        if -1 == lFileSize: lFileSize = '??'
        else: lFileSize = formatBytes(float(lFileSize))
        # download speed
        dSpeed = self.downloader.getDownloadSpeed()
        if -1 == dSpeed: dSpeed = ''
        else: dSpeed = formatBytes(float(dSpeed))

        speed = self.downloader.getDownloadSpeed()
        tmpStr = ''
        if 0 < self.downloader.getLocalFileSize():
            if 0 <= self.downloader.getRemoteFileSize():
                tmpStr = "\n%s/%s" % (lFileSize, rFileSize)
            else:
                tmpStr = "\n%s" % (lFileSize)
            if 0 <= dSpeed:
                tmpStr += "\n%s/s" % (dSpeed)
        else:
            tmpStr += '\n\n'

        self["console"].setText(self.movieTitle + tmpStr)
        if tmpBuffSize > self.requestedBuffSize: percentage = 100
        else: percentage = (100 * tmpBuffSize) / self.requestedBuffSize
        self["percentage"].setText(str(percentage))
        self["icon"].nextFrame()

        # check if we start move player
        if self.canRunMoviePlayer:
            if tmpBuffSize >= self.requestedBuffSize or (
                    self.downloader.getStatus() == DMHelper.STS.DOWNLOADED
                    and 0 < self.downloader.getLocalFileSize()):
                self.runMovePlayer()
                return

        # check if it is downloading
        if self.downloader.getStatus() not in [
                DMHelper.STS.DOWNLOADING, DMHelper.STS.WAITING
        ]:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                "Nastąpił błąd pobierania. \nStatus[%s], tmpBuffSize[%r], canRunMoviePlayer[%r]"
                % (self.downloader.getStatus(), tmpBuffSize,
                   self.canRunMoviePlayer),
                type=MessageBox.TYPE_ERROR,
                timeout=10)
            self.canRunMoviePlayer = False
            # stop timer before message
            self.setMainTimerSts(False)

        return
Exemplo n.º 22
0
    def downloaderPageContent(self, webDM, currList):
        DM_status = ''
        tempText = '<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n'
        tempText += IncludeMENU()
        tempText += '<div class="main">\n'
        if webDM is None:
            tempText += '<table border="0" cellspacing="15px"><tbody>\n'
            tempText += '<td><b><font color="#FFE4C4">%s</font></b></td>' % _(
                'Download manager is not initialized')
            tempText += '<td>' + formSUBMITvalue([
                ('cmd', 'initDM')
            ], _("Initialize Download Manager")) + '</td>'
            tempText += '</tbody></table>\n'
        else:
            tempText += '<table border="0" cellspacing="15px"><tbody><tr>\n'
            if not webDM.isRunning():
                DM_status = _("STOPPED")
                tempText += '<td>' + formSUBMITvalue(
                    [('cmd', 'stopDM')], _("Stop"),
                    'disabled style="background-color:#ff6400"') + '</td>'
                tempText += '<td>' + formSUBMITvalue([
                    ('cmd', 'runDM')
                ], _("Start"), 'style="background-color:#00FF00"') + '</td>'
            else:
                DM_status = _("STARTED")
                tempText += '<td>' + formSUBMITvalue([
                    ('cmd', 'stopDM')
                ], _("Stop"), 'style="background-color:#ff6400"') + '</td>'
                tempText += '<td>' + formSUBMITvalue(
                    [('cmd', 'runDM')], _("Start"),
                    'disabled style="background-color:#00FF00"') + '</td>'
                #tempText += '<td><b><font color="#ccE4C4">%s</font></b></td>' % _('Start')
            tempText += '<td>' + formSUBMITvalue([
                ('cmd', 'arvchiveDM')
            ], _("Archive"), 'style="background-color:yellow"') + '</td>'
            tempText += '<td>' + formSUBMITvalue(
                [('cmd', 'downloadsDM')], _("Downloads"),
                'style="background-color:#0080FF"') + '</td></tr>\n'
            tempText += '<tr><td colspan="2">%s</td><td colspan="2">%s</td></tr>' % (
                _("Manager status: "), DM_status)
            tempText += '</tbody></table>\n'

            #display the list of downloads
            tempText += '<table  width="800px" cellspacing="5px"><tbody>\n'
            for item in currList:
                # Downloaded Size
                info1 = formatBytes(item.downloadedSize)

                # File Size
                if item.fileSize > 0:
                    info1 += "/" + formatBytes(item.fileSize)

                elif item.totalFileDuration > 0 and item.downloadedFileDuration > 0:
                    totalDuration = item.totalFileDuration
                    downloadDuration = item.downloadedFileDuration
                    totalDuration = str(timedelta(seconds=totalDuration))
                    downloadDuration = str(timedelta(seconds=downloadDuration))
                    if totalDuration.startswith('0:'):
                        totalDuration = totalDuration[2:]
                    if downloadDuration.startswith('0:'):
                        downloadDuration = downloadDuration[2:]
                    info1 = "{0}/{1} ({2})".format(downloadDuration,
                                                   totalDuration, info1)

                # Downloaded Procent
                if item.downloadedProcent >= 0:
                    info1 += ", " + str(item.downloadedProcent) + "%"

                # Download Speed
                info2 = info1 + ", " + formatBytes(item.downloadedSpeed) + "/s"

                try:
                    fileName = item.fileName.split('/')[-1]
                except Exception:
                    fileName = item.fileName
                if DMHelper.STS.WAITING == item.status:
                    status = _("PENDING")
                    icon = '<img border="0" src="./icons/iconwait1.png" width="64" height="64">'
                    info = ''
                    buttons = ''
                elif DMHelper.STS.DOWNLOADING == item.status:
                    status = _("DOWNLOADING")
                    icon = '<img border="0" src="./icons/iconwait2.png" width="64" height="64">'
                    info = info2
                    buttons = '<table><tbody><tr><td>%s</td><td>%s</td></tr></tbody></table>' % (
                        formSUBMITvalue([('watchMovie', item.fileName)],
                                        _("Watch")),
                        formSUBMITvalue([('stopDownload', item.downloadIdx)],
                                        _("Stop download")))

                elif DMHelper.STS.DOWNLOADED == item.status and item.url[:
                                                                         1] == '/':  # for Archive section
                    status = _("DOWNLOADED")
                    icon = '<img border="0" src="./icons/icondone.png" width="64" height="64">'
                    info = info1
                    buttons = '<table><tbody><tr><td>%s</td><td>%s</td></tr></tbody></table>' % (
                        formSUBMITvalue([('cmd', 'arvchiveDM'),
                                         ('cmd', 'watchMovie'),
                                         ('cmd', item.fileName)], _("Watch")),
                        formSUBMITvalue([('cmd', 'arvchiveDM'),
                                         ('cmd', 'deleteMovie'),
                                         ('cmd', item.fileName)], _("Delete")))

                elif DMHelper.STS.DOWNLOADED == item.status:
                    status = _("DOWNLOADED")
                    icon = '<img border="0" src="./icons/icondone.png" width="64" height="64">'
                    info = info1
                    buttons = '<table><tbody><tr><td>%s</td><td>%s</td><td>%s</td></tr></tbody></table>' % (
                        formSUBMITvalue([('watchMovie', item.fileName)],
                                        _("Watch")),
                        formSUBMITvalue([('downloadAgain', item.downloadIdx)],
                                        _("Download again")),
                        formSUBMITvalue([('removeMovie', item.downloadIdx)],
                                        _("Delete")))
                elif DMHelper.STS.INTERRUPTED == item.status:
                    status = _("ABORTED")
                    icon = '<img border="0" src="./icons/iconerror.png" width="64" height="64">'
                    info = info1
                    buttons = '<table><tbody><tr><td>%s</td><td>%s</td><td>%s</td></tr></tbody></table>' % (
                        formSUBMITvalue([('watchMovie', item.fileName)],
                                        _("Watch")),
                        formSUBMITvalue([('downloadAgain', item.downloadIdx)],
                                        _("Download again")),
                        formSUBMITvalue([('removeMovie', item.downloadIdx)],
                                        _("Delete")))
                elif DMHelper.STS.ERROR == item.status:
                    status = _("DOWNLOAD ERROR")
                    icon = '<img border="0" src="./icons/iconwarning.png" width="64" height="64">'
                    info = ''
                    buttons = '<table><tbody><tr><td>%s</td><td>%s</td></tr></tbody></table>' % (
                        formSUBMITvalue([('downloadAgain', item.downloadIdx)],
                                        _("Download again")),
                        formSUBMITvalue([('removeMovie', item.downloadIdx)],
                                        _("Delete")))
                elif item.status == 'INFO':
                    status = ''
                    icon = '<img border="0" src="./icons/iconwarning.png" width="64" height="64">'
                    info = ''
                    buttons = ''
                else:
                    status = ''
                    icon = ''
                    info = ''
                    buttons = ''
                tempText += tableHorizontalRedLine(colspan=3)
                tempText += '<tr><td rowspan="4" align="center">%s</td><td colspan="2"><b>%s</b></td></tr>\n' % (
                    icon, fileName)
                tempText += '<tr><td><div style="text-indent: 20px">%s</div></td></tr>\n' % item.url
                tempText += '<tr><td>%s</td><td align="right">%s</td></tr>\n' % (
                    info, status)
                tempText += '<tr><td colspan="3" align="right">%s</td></tr>\n' % (
                    buttons)
            tempText += tableHorizontalRedLine(colspan=3)
            tempText += '</tbody></table>\n'
        tempText += '</div></body>\n'
        return tempText