src/streamlink/plugins/vk.py
def _get_streams(self):
        """
        Find the streams for vk.com
        :return:
        """
        self.session.http.headers.update({'User-Agent': useragents.IPHONE_6})

        # If this is a 'videos' catalog URL
        # with an video ID in the GET request, get that instead
        url = self.follow_vk_redirect(self.url)

        m = self._url_re.match(url)
        if not m:
            log.error('URL is not compatible: {0}'.format(url))
            return

        video_id = m.group('video_id')
        log.debug('video ID: {0}'.format(video_id))

        params = {
            'act': 'show_inline',
            'al': '1',
            'video': video_id,
        }
        res = self.session.http.post(self.API_URL, params=params)

        for _i in itertags(res.text, 'iframe'):
            if _i.attributes.get('src'):
                iframe_url = update_scheme(self.url, _i.attributes['src'])
                log.debug('Found iframe: {0}'.format(iframe_url))
                for s in self.session.streams(iframe_url).items():
                    yield s

        for _i in itertags(res.text, 'source'):
            if _i.attributes.get('type') == 'application/vnd.apple.mpegurl':
                video_url = _i.attributes['src']
                # Remove invalid URL
                if video_url.startswith('https://vk.com/'):
                    continue
                streams = HLSStream.parse_variant_playlist(self.session,
                                                           video_url)
                if not streams:
                    yield 'live', HLSStream(self.session, video_url)
                else:
                    for s in streams.items():
                        yield s
            elif _i.attributes.get('type') == 'video/mp4':
                q = 'vod'
                video_url = _i.attributes['src']
                m = self._vod_quality_re.search(video_url)
                if m:
                    q = '{0}p'.format(m.group(1))
                yield q, HTTPStream(self.session, video_url)
def _get_streams(self):
        """
        Find the streams for vk.com
        :return:
        """
        self.session.http.headers.update({'User-Agent': useragents.IPHONE_6})

        # If this is a 'videos' catalog URL
        # with an video ID in the GET request, get that instead
        url = self.follow_vk_redirect(self.url)

        m = self._url_re.match(url)
        if not m:
            log.error('URL is not compatible: {0}'.format(url))
            return

        video_id = m.group('video_id')
        log.debug('video ID: {0}'.format(video_id))

        params = {
            'act': 'show_inline',
            'al': '1',
            'video': video_id,
        }
        res = self.session.http.post(self.API_URL, params=params)

        for _i in itertags(res.text, 'iframe'):
            if _i.attributes.get('src'):
                iframe_url = update_scheme(self.url, _i.attributes['src'])
                log.debug('Found iframe: {0}'.format(iframe_url))
                for s in self.session.streams(iframe_url).items():
                    yield s

        for _i in itertags(res.text, 'source'):
            if _i.attributes.get('type') == 'application/vnd.apple.mpegurl':
                video_url = _i.attributes['src']
                # Remove invalid URL
                if video_url.startswith('https://vk.com/'):
                    continue
                streams = HLSStream.parse_variant_playlist(self.session,
                                                           video_url)
                if not streams:
                    yield 'live', HLSStream(self.session, video_url)
                else:
                    for s in streams.items():
                        yield s
            elif _i.attributes.get('type') == 'video/mp4':
                q = 'vod'
                video_url = _i.attributes['src']
                m = self._vod_quality_re.search(video_url)
                if m:
                    q = '{0}p'.format(m.group(1))
                yield q, HTTPStream(self.session, video_url)
def _get_streams ( self ) : self . session . http . headers . update ( { 'User-Agent' : useragents . IPHONE_6 } ) # If this is a 'videos' catalog URL # with an video ID in the GET request, get that instead url = self . follow_vk_redirect ( self . url ) m = self . _url_re . match ( url ) if not m : log . error ( 'URL is not compatible: {0}' . format ( url ) ) return video_id = m . group ( 'video_id' ) log . debug ( 'video ID: {0}' . format ( video_id ) ) params = { 'act' : 'show_inline' , 'al' : '1' , 'video' : video_id , } res = self . session . http . post ( self . API_URL , params = params ) for _i in itertags ( res . text , 'iframe' ) : if _i . attributes . get ( 'src' ) : iframe_url = update_scheme ( self . url , _i . attributes [ 'src' ] ) log . debug ( 'Found iframe: {0}' . format ( iframe_url ) ) for s in self . session . streams ( iframe_url ) . items ( ) : yield s for _i in itertags ( res . text , 'source' ) : if _i . attributes . get ( 'type' ) == 'application/vnd.apple.mpegurl' : video_url = _i . attributes [ 'src' ] # Remove invalid URL if video_url . startswith ( 'https://vk.com/' ) : continue streams = HLSStream . parse_variant_playlist ( self . session , video_url ) if not streams : yield 'live' , HLSStream ( self . session , video_url ) else : for s in streams . items ( ) : yield s elif _i . attributes . get ( 'type' ) == 'video/mp4' : q = 'vod' video_url = _i . attributes [ 'src' ] m = self . _vod_quality_re . search ( video_url ) if m : q = '{0}p' . format ( m . group ( 1 ) ) yield q , HTTPStream ( self . session , video_url )
Find the streams for vk.com
        :return:
Find the streams for vk . com : return :