o
    Ikc
                     @   sl   d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 e
eZeedG dd deZeZdS )	z{
$description 24-hour world, US and local news channel, based in the United States of America.
$url nbcnews.com
$type live
    N)Pluginpluginmatcher)validate)	HLSStreamz#https?://(?:www\.)?nbcnews\.com/nowc                   @   s    e Zd ZdZdZdZdd ZdS )NBCNewszehttps://api-leap.nbcsports.com/feeds/assets/{}?application=NBCNews&format=nbc-player&platform=desktopz%https://tokens.playmakerservices.com/zNBC News Nowc                 C   s$  | j jj| jtt tdtt	 dt itdt
dd d| _| jd u r0d S td| j  | j jj| j| jtt	 ddd	d
tjtddigiigitdd}| j jj| jd| jdddddddd|dtt	 ddt igitdd}t| j |S )Nz0.//script[@type='application/ld+json'][1]/text()embedUrlc                 S   s   |  dd S )N/)split)	embed_url r   </usr/lib/python3/dist-packages/streamlink/plugins/nbcnews.py<lambda>$   s    z&NBCNews._get_streams.<locals>.<lambda>)schemazAPI ID: videoSources
cdnSourcesprimary	sourceUrlz.m3u8)path)r   r   r   r   r   r   nbcnews	NBCSportsv1desktop falseunauthakamai)requestorIdpidapplicationversionplatformtoken
resourceIdinPathauthenticationTypecdnurltokenizedUrl)r   r   r(   )jsonr   )sessionhttpgetr'   r   Schema
parse_htmlxml_xpath_stringnone_or_all
parse_json	transformidlogdebugURL_APIformatendswithpost	URL_TOKENr   parse_variant_playlist)selfstreamr'   r   r   r   _get_streams   sn   

	zNBCNews._get_streamsN)__name__
__module____qualname__r6   r:   titler>   r   r   r   r   r      s
    r   )__doc__loggingrestreamlink.pluginr   r   streamlink.plugin.apir   streamlink.stream.hlsr   	getLoggerr?   r4   compiler   
__plugin__r   r   r   r   <module>   s    
E