
    OJni                     R    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	  G d de	      Z
y)	    N   )
StreamDatawrap_stream)	async_req   )BaseLiveStreamc                        e Zd ZdZddedz  dedz  f fdZdefdZdded	edefd
Z	e
ddedeez  dz  defd       Z xZS )VVXQLiveStreamzK
    A class for fetching and processing VVXQ live stream information.
    N
proxy_addrcookiesc                 P    t         |   ||       | j                         | _        y N)super__init___get_mobile_headersmobile_headers)selfr   r   	__class__s      U/home/uftp/myenv/lib/python3.12/site-packages/streamget/platforms/vvxq/live_stream.pyr   zVVXQLiveStream.__init__   s#    W-"668    returnc                 .    dddd| j                   xs ddS )Nz;ios/7.830 (ios 17.0; ; iPhone 15 (A2846/A3089/A3090/A3092))GETzhttps://h5webcdn-pro.vvxqiu.comz https://h5webcdn-pro.vvxqiu.com/ )z
user-agentzaccess-control-request-methodoriginreferercookie)r   )r   s    r   r   z"VVXQLiveStream._get_mobile_headers   s$    W-279ll(b
 	
r   urlprocess_datac                 P  K   | j                  |d      }d| d}t        || j                  | j                         d{   }t	        j
                  |      }|d   d   }|srddd	d|d
}t        dt        j                  j                  |       | j                  | j                         d{   }t	        j
                  |      }|d   d   d   }|dd}	d| d|dd  d}
t        |
| j                  | j                         d{   }d|vr	|	d|
|
dz  }	|	S 7 7 p7 w)a)  
        Fetches web stream data for a live room.

        Args:
            url (str): The room URL.
            process_data (bool): Whether to process the data. Defaults to True.

        Returns:
            dict: A dictionary containing anchor name, live status, room URL, and title.
        roomIdzNhttps://h5p.vvxqiu.com/activity-center/fanclub/activity/captain/banner?roomId=z&product=vvstar)r   headersNdata
anchorNamer   vvstar)	sessionIduserIdproduct	tickTokenr!   z<https://h5p.vvxqiu.com/activity-center/halloween2023/banner?memberVO
memberNameF)anchor_nameis_livez2https://liveplay-pro.wasaixiu.com/live/1400442770__r   z_single.m3u8z	Not FoundT)r-   m3u8_url
record_url)	
get_paramsr   r   r   jsonloadsurllibparse	urlencode)r   r   r   room_idapi_1json_str	json_datar,   paramsresultr/   resps               r   fetch_web_stream_dataz$VVXQLiveStream.fetch_web_stream_data   sP     //#x0`ah`iixy"5T__dNaNabbJJx(	'5#!F 'Nv||OeOeflOmNno??D4G4G H 

8,I#F+J7EK!,?GyPQRYZ[Z\R]Q^^jkxDOOTM`M`aad"$HHUUF/ c bs7   >D& D A0D&1D"2AD&D$D&"D&$D&r:   video_qualityc                 .   K   | ddiz  } t        |       S w)z_
        Fetches the stream URL for a live room and wraps it into a StreamData object.
        platformu   VV星球直播)r   )r:   r?   s     r   fetch_stream_urlzVVXQLiveStream.fetch_stream_url@   s#     
 	j"233	9%%s   )NN)Tr   )__name__
__module____qualname____doc__strr   dictr   boolr>   staticmethodintr   rB   __classcell__)r   s   @r   r
   r
   	   s~    93: 9sTz 9
T 
$s $$ $RV $L &$ &sSy4?O &[e & &r   r
   )r2   urllib.parser4   r#   r   r   requests.async_httpr   baser   r
    r   r   <module>rQ      s       + , !=&^ =&r   