Пример #1
0
 def _updateM3U8Finished(self, code=0):
     printDBG('m3u8 _updateM3U8Finished update code[%d]--- ' % (code))
     if self.liveStream and self.M3U8Updater:
         if 0 < len(self.M3U8ListData) and 0 == code:
             try:
                 m3u8Obj = m3u8.inits(self.M3U8ListData, self.m3u8Url)
                 if self.liveStream and not m3u8Obj.is_variant:
                     self.refreshDelay = int(m3u8Obj.target_duration)
                     if self.refreshDelay < 5:
                         self.refreshDelay = 5
                     if 0 < len(m3u8Obj.segments):
                         newFragments = [
                             self._segUri(seg.absolute_uri)
                             for seg in m3u8Obj.segments
                         ]
                         #self.mergeFragmentsList(newFragments)
                         self.mergeFragmentsListWithChecking(
                             newFragments,
                             m3u8Obj.media_sequence + len(m3u8Obj.segments))
                         printDBG(
                             'm3u8 _updateM3U8Finished list updated ---')
             except Exception:
                 printDBG(
                     "m3u8 _updateM3U8Finished exception url[%s] data[%s]" %
                     (self.m3u8Url, self.M3U8ListData))
         else:
             printDBG('m3u8 _updateM3U8Finished no data ---')
         # hardcode
         self.M3U8UpdaterRefreshDelay += 1
         if self.refreshDelay < self.M3U8UpdaterRefreshDelay or 0 != code:
             self.M3U8UpdaterRefreshDelay = 0
             self.M3U8ListData = ''
             m3u8Url = self._addTimeStampToUrl(self.m3u8Url)
             printDBG(
                 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [%s]"
                 % m3u8Url)
             cmd = DMHelper.getBaseWgetCmd(self.downloaderParams) + (
                 ' --tries=0 --timeout=%d ' %
                 self._getTimeout()) + '"' + m3u8Url + '" -O - 2> /dev/null'
             printDBG("m3u8 _updateM3U8Finished download cmd[%s]" % cmd)
             self.M3U8Updater.execute(E2PrioFix(cmd))
             return
         else:
             self.M3U8Updater.execute(E2PrioFix("sleep 1"))
             return
     printDBG(
         "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
     printDBG(
         "||||||||||||| m3u8 _updateM3U8Finished FINISHED |||||||||||||")
     printDBG(
         "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
Пример #2
0
    def start(self, url, filePath, params={}):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url = url
        self.filePath = filePath
        self.downloaderParams = params
        self.fileExtension = ''  # should be implemented in future

        self.outData = ''
        self.contentType = 'unknown'

        cmd = "python " + DMHelper.GET_PWGET_PATH(
        ) + ' "' + self.url + '" "' + self.filePath + '" > /dev/null'
        printDBG("Download cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(
            self.console.stderrAvail, self._dataAvail)

        self.console.execute(E2PrioFix(cmd))

        self.wgetStatus = self.WGET_STS.CONNECTING
        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
Пример #3
0
    def start(self, url, filePath, params={}, info_from=None, retries=0):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url = url
        self.filePath = filePath
        self.downloaderParams = params
        self.fileExtension = ''  # should be implemented in future

        self.outData = ''
        self.contentType = 'unknown'
        if None == info_from:
            info_from = WgetDownloader.INFO.FROM_FILE
        self.infoFrom = info_from

        cmd = 'wget ' + '"' + self.url + '" -O "' + self.filePath + '" > /dev/null'
        printDBG("Download cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console.execute(E2PrioFix(cmd))

        self.wgetStatus = self.WGET_STS.CONNECTING
        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
    def doStartDownload(self):
        self.outData = ''
        self.contentType = 'unknown'
        filePath = self.multi['files'][self.currIdx]
        url = self.multi['urls'][self.currIdx]

        info = ""
        retries = 0

        cmd = DMHelper.getBaseWgetCmd(self.downloaderParams) + (
            ' %s -t %d ' % (info, retries)
        ) + '"' + url + '" -O "' + filePath + '" > /dev/null'
        printDBG("doStartDownload cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(
            self.console.stderrAvail, self._dataAvail)
        self.console.execute(E2PrioFix(cmd))

        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
Пример #5
0
 def requestRefresh(self):
     if self.underClosing: return
     if self.underRefreshing: return
     self.underRefreshing = True
     self.tmpList = []
     self.tmpData = ''
     cmd = self.prepareCmd()
     printDBG("IPTVDirectorySelectorWidget.requestRefresh cmd[%s]" % cmd)
     self.console.execute(E2PrioFix(cmd))
    def start(self, url, filePath, params={}, info_from=None, retries=0):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url = url
        self.filePath = filePath
        self.downloaderParams = params
        self.fileExtension = ''  # should be implemented in future

        rtmpdump_url = self._getCMD(url)

        if 0:
            #rtmpdump -r rtmp://5.79.71.195/stream/ --playpath=3001_goldvod --swfUrl=http://goldvod.tv:81/j/jwplayer/jwplayer.flash.swf --pageUrl=http://goldvod.tv/tv-online/tvp1.html -o tvp1.flv
            tmpTab = url.split(' ')
            rtmpdump_url = '"' + tmpTab[0].strip() + '"'
            del tmpTab[0]

            prevflashVer = ''
            for item in tmpTab:
                item = item.strip()
                # ignore empty and live params
                if '' != prevflashVer:
                    rtmpdump_url += ' --' + prevflashVer[
                        0:-1] + ' ' + item + '"'
                    prevflashVer = ''
                    continue
                idx = item.find('=')
                if -1 == idx: continue
                argName = item[:idx]
                argValue = item[idx + 1:]
                if 'live' in argName:
                    item = 'live'
                else:
                    item = '%s="%s"' % (argName, argValue)

                if 'flashVer' == argName:
                    prevflashVer = item
                    continue
                rtmpdump_url += ' --' + item
        cmd = DMHelper.GET_RTMPDUMP_PATH(
        ) + " " + rtmpdump_url + ' --realtime -o "' + self.filePath + '" > /dev/null 2>&1'
        printDBG("rtmpdump cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        #self.console.stderrAvail.append( self._dataAvail )
        self.console.execute(E2PrioFix(cmd))

        self.rtmpStatus = self.RTMP_STS.CONNECTING
        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
 def doStartPostProcess(self):
     cmd = DMHelper.GET_FFMPEG_PATH() + ' '
     for item in self.multi['files']:
         cmd += ' -i "{0}" '.format(item)
     cmd += ' -map 0:0 -map 1:0 -vcodec copy -acodec copy "{0}" >/dev/null 2>&1 '.format(
         self.filePath)
     printDBG("doStartPostProcess cmd[%s]" % cmd)
     self.console = eConsoleAppContainer()
     self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                    self._cmdFinished)
     self.console.execute(E2PrioFix(cmd))
 def yellow_pressed(self):
     if self.iptvclosing: return
     if not self.underRefreshing: 
         self.underRefreshing = True
         self.tmpList = []
         self.tmpData = ''
         lsdirPath = GetBinDir("lsdir")
         try: os_chmod(lsdirPath, 0777)
         except Exception: printExc()
         cmd = '%s "%s" rl r' % (lsdirPath, config.plugins.iptvplayer.NaszaSciezka.value)
         printDBG("cmd[%s]" % cmd)
         self.console.execute( E2PrioFix( cmd ) )
     
     self.localMode = True
     self.reloadList(True)
     return
Пример #9
0
 def _startM3U8(self, wait=0):
     self.outData = ''
     ##############################################################################
     # frist download m3u8 conntent
     ##############################################################################
     self.downloadType = self.DOWNLOAD_TYPE.M3U8
     m3u8Url = self._addTimeStampToUrl(self.m3u8Url)
     cmd = DMHelper.getBaseWgetCmd(self.downloaderParams) + (
         ' --tries=0 --timeout=%d ' %
         self._getTimeout()) + '"' + m3u8Url + '" -O - 2> /dev/null'
     if wait > 0:
         cmd = (' sleep %s && ' % wait) + cmd
     printDBG("Download cmd[%s]" % cmd)
     self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                    self._cmdFinished)
     self.console_stdoutAvail_conn = eConnectCallback(
         self.console.stdoutAvail, self._dataAvail)
     self.console.execute(E2PrioFix(cmd))
    def start(self, uri, mode='loop'):
        self.uri = uri
        self.playMode = mode

        gstplayerPath = config.plugins.iptvplayer.gstplayerpath.value
        #'export GST_DEBUG="*:6" &&' +
        cmd = gstplayerPath + ' "%s"' % self.uri
        if "://" in self.uri:
            cmd += ' "%s" "%s"  "%s"  "%s" ' % (
                self.gstAdditionalParams['download-buffer-path'],
                self.gstAdditionalParams['ring-buffer-max-size'],
                self.gstAdditionalParams['buffer-duration'],
                self.gstAdditionalParams['buffer-size'])
            tmp = strwithmeta(self.uri)
            url, httpParams = DMHelper.getDownloaderParamFromUrl(tmp)
            for key in httpParams:
                cmd += (' "%s=%s" ' % (key, httpParams[key]))
            if 'http_proxy' in tmp.meta:
                tmp = tmp.meta['http_proxy']
                if '://' in tmp:
                    if '@' in tmp:
                        tmp = re.search('([^:]+?://)([^:]+?):([^@]+?)@(.+?)$',
                                        tmp)
                        if tmp:
                            cmd += (
                                ' "proxy=%s" "proxy-id=%s" "proxy-pw=%s" ' %
                                (tmp.group(1) + tmp.group(4), tmp.group(2),
                                 tmp.group(3)))
                    else:
                        cmd += (' "proxy=%s" ' % tmp)
        else:
            cmd = 'exteplayer3 "%s"' % self.uri + " > /dev/null"
        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._playerFinished)
        printDBG("IPTVSimpleAudioPlayer.start cmd[%s]" % cmd)
        self.console.execute(E2PrioFix(cmd))
        self.stopped = False
Пример #11
0
    def start(self, url, filePath, params={}):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url = url
        self.filePath = filePath
        self.downloaderParams = params
        self.fileExtension = ''  # should be implemented in future
        self.outData = ''
        self.contentType = 'unknown'

        # baseWgetCmd = DMHelper.getBaseWgetCmd(self.downloaderParams)
        # TODO: add all HTTP parameters
        addParams = ''
        meta = strwithmeta(url).meta
        if 'iptv_m3u8_key_uri_replace_old' in meta and 'iptv_m3u8_key_uri_replace_new' in meta:
            addParams = ' -k "%s" -n "%s" ' % (
                meta['iptv_m3u8_key_uri_replace_old'],
                meta['iptv_m3u8_key_uri_replace_new'])

        cmd = DMHelper.getBaseHLSDLCmd(
            self.downloaderParams) + (' "%s"' % self.url) + addParams + (
                ' -o "%s"' % self.filePath) + ' > /dev/null'

        printDBG("HLSDownloader::start cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(
            self.console.stderrAvail, self._dataAvail)
        self.console.execute(E2PrioFix(cmd))

        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
    def start(self, url, filePath, params={}):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url = url
        self.filePath = filePath
        self.downloaderParams = params
        self.fileExtension = ''  # should be implemented in future
        if 'ustream.tv' in url:
            self.streamSelector = strwithmeta(url).meta.get(
                'iptv_chank_url', '')
        else:
            self.streamSelector = strwithmeta(url).meta.get('iptv_bitrate', 0)

        self.outData = ''
        self.contentType = 'unknown'

        baseWgetCmd = DMHelper.getBaseWgetCmd(self.downloaderParams)

        cmd = DMHelper.GET_F4M_PATH() + (" '%s'" % baseWgetCmd) + (
            ' "%s"' % self.url) + (' "%s"' % self.filePath) + (
                ' %s' % self.streamSelector) + ' > /dev/null'

        printDBG("F4mDownloader::start cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(
            self.console.stderrAvail, self._dataAvail)
        self.console.execute(E2PrioFix(cmd))

        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
Пример #13
0
    def _startFragment(self, tryAgain=False):
        printDBG("_startFragment tryAgain[%r]" % tryAgain)
        self.outData = ''
        self.remoteFragmentSize = -1
        self.remoteFragmentType = 'unknown'

        if 0 > self.localFileSize:
            self.m3u8_prevLocalFileSize = 0
        else:
            self.m3u8_prevLocalFileSize = self.localFileSize
        ##############################################################################
        # frist download nextFragment conntent
        ##############################################################################
        self.downloadType = self.DOWNLOAD_TYPE.SEGMENT

        if None != self.console:
            self.console_appClosed_conn = None
            self.console_stderrAvail_conn = None
        #self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(
            self.console.stderrAvail, self._dataAvail)

        if tryAgain and self.tries >= self.MAX_RETRIES:
            if not self.liveStream:
                return DMHelper.STS.INTERRUPTED
            else:
                # even if fragment is lost this is not big problem, download next one,
                # this is a live stream this can happen :)
                tryAgain = False

        currentFragment = None
        if False == tryAgain:
            self.tries = 0
            if (self.currentFragment + 1) < len(self.fragmentList):
                self.currentFragment += 1
                currentFragment = self.fragmentList[self.currentFragment]
        else:
            self.tries += 1
            currentFragment = self.fragmentList[self.currentFragment]

        if None != currentFragment:
            self.wgetStatus = self.WGET_STS.CONNECTING
            cmd = DMHelper.getBaseWgetCmd(self.downloaderParams) + (
                ' --tries=1 --timeout=%d ' % self._getTimeout()
            ) + '"' + currentFragment + '" -O - >> "' + self.filePath + '"'
            printDBG("Download cmd[%s]" % cmd)
            self.console.execute(E2PrioFix(cmd))

            #DebugToFile(currentFragment)
            return DMHelper.STS.DOWNLOADING
        else:
            if self.liveStream:
                # we are in live so wait for new fragments
                printDBG(
                    "m3u8 downloader - wait for new fragments ----------------------------------------------------------------"
                )
                self.downloadType = self.DOWNLOAD_TYPE.WAITTING
                self.console.execute(E2PrioFix("sleep 2"))
                return DMHelper.STS.DOWNLOADING
            else:
                return DMHelper.STS.DOWNLOADED