Пример #1
0
 def _get_streams(self):
     log.debug('Version 2018-07-01')
     log.info('This is a custom plugin. '
              'For support visit https://github.com/back-to/plugins')
     url_match = _url_re.match(self.url)
     channel = url_match.group('channel')
     log.debug('Channel name: {0}'.format(channel))
     http.parse_headers('Referer: %s' % self.url)
     http.parse_cookies('accept_rules=true')
     page = http.get(self.url)
     ws_url = self._get_websocket(page.text)
     log.debug('WebSocket: {0}'.format(ws_url))
     stream_id, rtmp_cdn = self._get_stream_id(channel, ws_url)
     if not (stream_id or rtmp_cdn):
         log.error('Channel is not available.')
         return
     log.debug('Stream ID: {0}'.format(stream_id))
     log.debug('RTMP CDN: {0}'.format(rtmp_cdn))
     stream = RTMPStream(
         self.session, {
             'rtmp': 'rtmp://{0}:1935/webrtc'.format(rtmp_cdn),
             'pageUrl': self.url,
             'playpath': '{0}_aac'.format(stream_id),
             'swfVfy': SWF_URL,
             'live': True
         })
     return {'live': stream}
Пример #2
0
    def _get_streams(self):
        log.debug('Version 2018-07-01')
        log.info('This is a custom plugin. '
                 'For support visit https://github.com/back-to/plugins')
        channel = self._url_re.match(self.url).group('channel')
        log.info('Channel: {0}'.format(channel))
        http.headers.update({'User-Agent': useragents.FIREFOX})
        http.parse_cookies('adult=1')
        res = http.get(self.url)

        m = self._streams_re.search(res.text)
        if not m:
            log.debug('No streams data found.')
            return

        m2 = self._user_re.search(res.text)
        if not m:
            log.debug('No user data found.')
            return

        _streams = parse_json(m.group('data'), schema=self._streams_schema)
        _user = parse_json(m2.group('data'), schema=self._user_schema)

        _x = []
        for _s in _streams:
            if _s.get('nick') == channel:
                _x = _s
                break

        if not _x:
            log.error('Channel is not available.')
            return

        app = 'videochat/?{0}'.format(_user['phash'])
        rtmp = 'rtmp://{0}/videochat/'.format(_x['server'])

        params = {
            'rtmp': rtmp,
            'pageUrl': self.url,
            'app': app,
            'playpath': _x['broadcasturl'],
            'swfVfy': self.SWF_URL,
            'live': True
        }
        return {'live': RTMPStream(self.session, params=params)}
Пример #3
0
 def add_cookies(self, cookies):
     http.parse_cookies(cookies, domain="twitch.tv")
Пример #4
0
 def add_cookies(self, cookies):
     http.parse_cookies(cookies, domain="twitch.tv")