<s> import re <EOL> from livestreamer . plugin import Plugin <EOL> from livestreamer . plugin . api import http , validate <EOL> from livestreamer . plugin . api . utils import parse_query <EOL> from livestreamer . stream import RTMPStream <EOL> VIEW_LIVE_API_URL = "<STR_LIT>" <EOL> VIEW_LIVE_API_URL_TW = "<STR_LIT>" <EOL> _url_re = re . compile ( "<STR_LIT>" ) <EOL> _url_re_tw = re . compile ( "<STR_LIT>" ) <EOL> _flashvars_re = re . compile ( '<STR_LIT>' ) <EOL> _flashvars_schema = validate . Schema ( <EOL> validate . transform ( _flashvars_re . findall ) , <EOL> validate . get ( <NUM_LIT:0> ) , <EOL> validate . transform ( parse_query ) , <EOL> validate . any ( <EOL> { <EOL> "<STR_LIT:s>" : validate . text , <EOL> "<STR_LIT:id>" : validate . text <EOL> } , <EOL> { } <EOL> ) <EOL> ) <EOL> _view_live_schema = validate . Schema ( <EOL> { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT>" : validate . text , <EOL> "<STR_LIT>" : validate . url ( scheme = "<STR_LIT>" ) <EOL> } ] <EOL> } , <EOL> } , <EOL> validate . get ( "<STR_LIT>" ) , <EOL> validate . get ( "<STR_LIT>" ) <EOL> ) <EOL> class AfreecaTV ( Plugin ) : <EOL> @ classmethod <EOL> def can_handle_url ( cls , url ) : <EOL> return _url_re . match ( url ) <EOL> def _get_streams ( self ) : <EOL> flashvars = http . get ( self . url , schema = _flashvars_schema ) <EOL> if not flashvars : <EOL> return <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : flashvars [ "<STR_LIT:id>" ] , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> if re . search ( _url_re_tw , self . url ) : <EOL> res = http . get ( VIEW_LIVE_API_URL_TW , params = params ) <EOL> else : <EOL> res = http . get ( VIEW_LIVE_API_URL , params = params ) <EOL> streams = http . json ( res , schema = _view_live_schema ) <EOL> for stream in streams : <EOL> stream_name = "<STR_LIT>" . format ( stream [ "<STR_LIT>" ] ) <EOL> stream_params = { <EOL> "<STR_LIT>" : stream [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : True <EOL> } <EOL> yield stream_name , RTMPStream ( self . session , stream_params ) <EOL> __plugin__ = AfreecaTV </s>
