<s> import re <EOL> from livestreamer . plugin import Plugin <EOL> from livestreamer . plugin . api import http , validate <EOL> from livestreamer . stream import RTMPStream <EOL> PLAYER_URL = "<STR_LIT>" <EOL> SWF_URL = "<STR_LIT>" <EOL> _url_re = re . compile ( """<STR_LIT>""" , re . VERBOSE ) <EOL> _js_var_re = re . compile ( "<STR_LIT>" ) <EOL> _rtmp_re = re . compile ( "<STR_LIT>" ) <EOL> def _parse_server_ip ( values ) : <EOL> octets = [ <EOL> values [ "<STR_LIT:a>" ] / values [ "<STR_LIT:f>" ] , <EOL> values [ "<STR_LIT:b>" ] / values [ "<STR_LIT:f>" ] , <EOL> values [ "<STR_LIT:c>" ] / values [ "<STR_LIT:f>" ] , <EOL> values [ "<STR_LIT:d>" ] / values [ "<STR_LIT:f>" ] , <EOL> ] <EOL> return "<STR_LIT:.>" . join ( str ( int ( octet ) ) for octet in octets ) <EOL> _schema = validate . Schema ( <EOL> validate . transform ( _js_var_re . findall ) , <EOL> validate . transform ( dict ) , <EOL> { <EOL> "<STR_LIT:a>" : validate . transform ( int ) , <EOL> "<STR_LIT:b>" : validate . transform ( int ) , <EOL> "<STR_LIT:c>" : validate . transform ( int ) , <EOL> "<STR_LIT:d>" : validate . transform ( int ) , <EOL> "<STR_LIT:f>" : validate . transform ( int ) , <EOL> "<STR_LIT>" : validate . text , <EOL> } , <EOL> validate . union ( { <EOL> "<STR_LIT>" : validate . transform ( _parse_server_ip ) , <EOL> "<STR_LIT:path>" : validate . all ( <EOL> validate . get ( "<STR_LIT>" ) , <EOL> validate . transform ( _rtmp_re . findall ) , <EOL> validate . get ( <NUM_LIT:0> ) <EOL> ) <EOL> } ) <EOL> ) <EOL> class LetOnTV ( Plugin ) : <EOL> @ classmethod <EOL> def can_handle_url ( self , url ) : <EOL> return _url_re . match ( url ) <EOL> def _get_streams ( self ) : <EOL> match = _url_re . match ( self . url ) <EOL> info = http . get ( PLAYER_URL , params = match . groupdict ( ) , schema = _schema ) <EOL> if not info [ "<STR_LIT:path>" ] : <EOL> return <EOL> app , playpath = info [ "<STR_LIT:path>" ] <EOL> stream = RTMPStream ( self . session , { <EOL> "<STR_LIT>" : "<STR_LIT>" . format ( info [ "<STR_LIT>" ] , app ) , <EOL> "<STR_LIT>" : playpath , <EOL> "<STR_LIT>" : self . url , <EOL> "<STR_LIT>" : SWF_URL , <EOL> "<STR_LIT>" : True <EOL> } ) <EOL> return dict ( live = stream ) <EOL> __plugin__ = LetOnTV </s>
