<s> from __future__ import unicode_literals <EOL> import re <EOL> import json <EOL> import itertools <EOL> from . common import InfoExtractor <EOL> from . . compat import ( <EOL> compat_urllib_request , <EOL> ) <EOL> class BambuserIE ( InfoExtractor ) : <EOL> IE_NAME = '<STR_LIT>' <EOL> _VALID_URL = r'<STR_LIT>' <EOL> _API_KEY = '<STR_LIT>' <EOL> _TEST = { <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : True , <EOL> } , <EOL> } <EOL> def _real_extract ( self , url ) : <EOL> mobj = re . match ( self . _VALID_URL , url ) <EOL> video_id = mobj . group ( '<STR_LIT:id>' ) <EOL> info_url = ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( self . _API_KEY , video_id ) ) <EOL> info_json = self . _download_webpage ( info_url , video_id ) <EOL> info = json . loads ( info_json ) [ '<STR_LIT:result>' ] <EOL> return { <EOL> '<STR_LIT:id>' : video_id , <EOL> '<STR_LIT:title>' : info [ '<STR_LIT:title>' ] , <EOL> '<STR_LIT:url>' : info [ '<STR_LIT:url>' ] , <EOL> '<STR_LIT>' : info . get ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : int ( info [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : int ( info [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : info [ '<STR_LIT:username>' ] , <EOL> '<STR_LIT>' : info [ '<STR_LIT>' ] , <EOL> } <EOL> class BambuserChannelIE ( InfoExtractor ) : <EOL> IE_NAME = '<STR_LIT>' <EOL> _VALID_URL = r'<STR_LIT>' <EOL> _STEP = <NUM_LIT:50> <EOL> _TEST = { <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> def _real_extract ( self , url ) : <EOL> mobj = re . match ( self . _VALID_URL , url ) <EOL> user = mobj . group ( '<STR_LIT:user>' ) <EOL> urls = [ ] <EOL> last_id = '<STR_LIT>' <EOL> for i in itertools . count ( <NUM_LIT:1> ) : <EOL> req_url = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) . format ( user = user , count = self . _STEP , last = last_id ) <EOL> req = compat_urllib_request . Request ( req_url ) <EOL> req . add_header ( '<STR_LIT>' , '<STR_LIT>' % user ) <EOL> data = self . _download_json ( <EOL> req , user , '<STR_LIT>' % i ) <EOL> results = data [ '<STR_LIT:result>' ] <EOL> if not results : <EOL> break <EOL> last_id = results [ - <NUM_LIT:1> ] [ '<STR_LIT>' ] <EOL> urls . extend ( self . url_result ( v [ '<STR_LIT>' ] , '<STR_LIT>' ) for v in results ) <EOL> return { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : user , <EOL> '<STR_LIT>' : urls , <EOL> } </s>
