예제 #1
0
def LogToFile():
    retVal = getE2config('logToFile', False)
    if retVal == False or getE2config('ClearLogFile', True) == True:
        for logPath in ('/home/root', '/tmp', '/hdd'):
            if os.path.exists(logPath + '/streamlinksrv.log'):
                os.system('rm -f /%s/streamlinksrv.log' % logPath)
    return retVal
예제 #2
0
    def getSetting(self,id=None):
        item = '"' + str(id) + '"'
        pass#print "In xbmcaddon-py id =", item     
        pass#print "In xbmcaddon-py self.path =", self.path          
        xfile = self.path + "/resources/settings.xml" 
        if not os.path.exists(xfile):
            xfile = '/usr/lib/python2.7/site-packages/emukodi/PluginsSettings/%s.xml' % self.callingID
        if not os.path.exists(xfile):
            return ''
        
        f = open(xfile, 'r').read()
        if item not in f:
            return ""

        lines = []
        lines = f.splitlines()
        for line in lines:
#            pass#print "In xbmcaddon-py line =", line
            if str(item) in line:
                pass#print "In xbmcaddon-py line B=", line
                n2 = line.find(" default", 0)
                n3 = line.find('"', n2)
                n4 = line.find('"', (n3+1))
                xtxt = line[(n3+1):n4]
                break

        ##print "In xbmcaddon xtxt B=", xtxt
        if xtxt.startswith("getE2config('"):
            #xtxt = xtxt.split("'")[1]
            xtxt = getE2config(xtxt.split("'")[1])
        return str(xtxt)
예제 #3
0
    def __init__(self, session, *streams, **options):
        if not self.is_usable(session):
            raise StreamError("cannot use FFMPEG")

        self.session = session
        self.process = None
        self.streams = streams

        self.is_muxed = options.pop("is_muxed", True)
        ofmt = options.pop("format", "matroska")
        outpath = options.pop("outpath", "pipe:1")
        videocodec = session.options.get(
            "ffmpeg-video-transcode") or options.pop("vcodec", "copy")
        audiocodec = session.options.get(
            "ffmpeg-audio-transcode") or options.pop("acodec", "copy")
        metadata = options.pop("metadata", {})
        maps = options.pop("maps", [])
        copyts = options.pop("copyts", False)

        self._cmd = [self.command(session), '-nostats', '-y']
        delayVideo = str(getE2config('WPvideoDelay', '0'))
        if delayVideo != '0':
            self._cmd.extend(['-itsoffset', delayVideo])

        if self.is_muxed:
            #self.pipes = [NamedPipe("ffmpeg-{0}-{1}".format(os.getpid(), random.randint(0, 1000))) for _ in self.streams]
            self.pipes = []
            self.pipesFiles = []
            for _ in self.streams:  #zmiana, zeby nie bylo duplikatow
                tmpName = "ffmpeg-{0}-{1}".format(os.getpid(),
                                                  random.randint(0, 1000))
                pipeFile = os.path.join(tempfile.gettempdir(), tmpName)
                if os.path.exists(pipeFile):
                    tmpName += str(random.randint(0, 9))
                #log.debug("pipeFile: {0}".format(pipeFile))
                self.pipes.extend([NamedPipe(tmpName)])
                self.pipesFiles.extend([pipeFile])
            #log.debug("pipeFile: {0}".format(self.pipesFiles))
            self.pipe_threads = [
                threading.Thread(target=self.copy_to_pipe,
                                 args=(self, stream, np))
                for stream, np in zip(self.streams, self.pipes)
            ]

            for np in self.pipes:
                self._cmd.extend(["-i", np.path])
        else:
            self._cmd.extend(["-i", self.streams[0]])

        self._cmd.extend(['-c:v', videocodec])
        self._cmd.extend(['-c:a', audiocodec])

        for m in maps:
            self._cmd.extend(["-map", str(m)])

        if copyts:
            self._cmd.extend(["-copyts"])
            self._cmd.extend(["-start_at_zero"])

        for stream, data in metadata.items():
            for datum in data:
                self._cmd.extend(["-metadata:{0}".format(stream), datum])

        self._cmd.extend(['-f', ofmt, outpath])

        log.debug("ffmpeg command: {0}".format(' '.join(self._cmd)))
        self.close_errorlog = False

        if session.options.get("ffmpeg-verbose"):
            self.errorlog = sys.stderr
        elif session.options.get("ffmpeg-verbose-path"):
            self.errorlog = open(session.options.get("ffmpeg-verbose-path"),
                                 "w")
            self.close_errorlog = True
        else:
            self.errorlog = devnull()
예제 #4
0
def remoteE2(url=''):
    global remoteE2standbyCMD
    if url.startswith('remoteE2/'):
        remoteE2standbyCMD = None
        retURL = ''
        remoteE2address = getE2config('remoteE2address', '192.168.1.8')
        remoteE2port = getE2config('remoteE2port', '8001')
        remoteE2username = getE2config('remoteE2username', 'root')
        remoteE2password = getE2config('remoteE2password', 'root')
        remoteE2zap = getE2config('remoteE2zap', True)
        remoteE2wakeup = getE2config('remoteE2wakeup', True)
        base64string = base64.b64encode('%s:%s' %
                                        (remoteE2username, remoteE2password))
        if remoteE2wakeup == True:
            #sprawdzenie stanu e2
            try:
                request = urllib2.Request('http://%s/web/powerstate' %
                                          remoteE2address)
                LOGGER.debug("request : {}", str(request))
                request.add_header("Authorization", "Basic %s" % base64string)
                response = urllib2.urlopen(request).read()
                LOGGER.debug("response : {}", str(response))
            except Exception as e:
                LOGGER.error("Exception : {}", str(e))
                return '/usr/lib/enigma2/python/Plugins/Extensions/StreamlinkConfig/streams/offline.mp4'
            #pobudka e2
            if '<e2instandby>' in str(response) and 'true' in str(response):
                try:
                    request = urllib2.Request(
                        'http://%s/web/powerstate?newstate=4' %
                        remoteE2address)
                    LOGGER.info("request wakeup: {}", str(request))
                    request.add_header("Authorization",
                                       "Basic %s" % base64string)
                    response = urllib2.urlopen(request).read()
                    LOGGER.debug("response : {}", str(response))
                    #prepare standby script
                    remoteE2standbyCMD = urllib2.Request(
                        'http://%s/web/powerstate?newstate=5' %
                        remoteE2address)
                    remoteE2standbyCMD.add_header("Authorization",
                                                  "Basic %s" % base64string)
                    LOGGER.debug("response : {}", str(response))
                except Exception as e:
                    LOGGER.error("Exception : {}", str(e))
                    return '/usr/lib/enigma2/python/Plugins/Extensions/StreamlinkConfig/streams/offline.mp4'
            else:
                LOGGER.info("tuner running: {}")
        #generate URL e.g. http://192.168.1.8:8001/1:0:1:3DD0:640:13E:820000:0:0:0
        url = url[9:].replace('-', ':')
        if remoteE2zap == True:
            try:
                request = urllib2.Request('http://%s/web/zap?sRef=%s' %
                                          (remoteE2address, url))
                LOGGER.info("request zap to: {}", str(request))
                request.add_header("Authorization", "Basic %s" % base64string)
                response = urllib2.urlopen(request).read()
                LOGGER.debug("response : {}", str(response))
            except Exception as e:
                LOGGER.error("Exception : {}", str(e))
                return '/usr/lib/enigma2/python/Plugins/Extensions/StreamlinkConfig/streams/offline.mp4'
        time.sleep(1)
        return 'http://%s:%s/%s' % (remoteE2address, remoteE2port, url)
    elif not remoteE2standbyCMD is None:
        LOGGER.info("request standby:")
        try:
            response = urllib2.urlopen(remoteE2standbyCMD).read()
            LOGGER.debug("response : {}", str(response))
        except Exception as e:
            LOGGER.error("Exception : {}", str(e))
    else:
        LOGGER.info(
            "Unknown option or something wrong (url = '%s', remoteE2standbyCMD = '%s'"
            % (url, str(remoteE2standbyCMD)))
    return
예제 #5
0
def GetLogFileName():
    return getE2config('logPath', '/tmp') + '/streamlinksrv.log'
예제 #6
0
def GetLogLevel():
    return getE2config(
        'logLevel', "info"
    )  # "critical", "error", "warning", "info", "debug", "trace" or "none"
예제 #7
0
def GetPortNumber():
    return getE2config(
        'PortNumber',
        8088)  # change it to 88 for livestreamersrv compatibility
예제 #8
0
    'login_url': 'https://pilot.wp.pl/api/v1/user_auth/login',
    'main_url': 'https://pilot.wp.pl/api/v1/channels/list?device=androidtv',
    'video_url': 'https://pilot.wp.pl/api/v1/channel/',
    'close_stream_url': 'https://pilot.wp.pl/api/v1/channels/close',
}

headers = {
    'user-agent': 'ExoMedia 4.3.0 (43000) / Android 8.0.0 / foster_e',
    'accept': 'application/json',
    'x-version': 'pl.videostar|3.25.0|Android|26|foster_e',
    'content-type': 'application/json; charset=UTF-8'
}

data = {
    'device': 'AndroidTV',
    'login': getE2config('WPusername'),
    'password': getE2config('WPpassword')
}

PreferDash = getE2config('WPpreferDASH', False)
videoDelay = getE2config('WPvideoDelay', 0)


def saveCookie(cookie):
    open(
        "/usr/lib/enigma2/python/Plugins/Extensions/StreamlinkConfig/plugins/pilotwppl.cookie",
        "w").write('%s' % cookie)


def getCookie():
    if os.path.exists(