<s> from __future__ import unicode_literals <EOL> import re <EOL> from . common import InfoExtractor <EOL> from . . compat import ( <EOL> compat_urlparse , <EOL> ) <EOL> class UstreamIE ( InfoExtractor ) : <EOL> _VALID_URL = r'<STR_LIT>' <EOL> IE_NAME = '<STR_LIT>' <EOL> _TEST = { <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> } , <EOL> } <EOL> def _real_extract ( self , url ) : <EOL> m = re . match ( self . _VALID_URL , url ) <EOL> video_id = m . group ( '<STR_LIT>' ) <EOL> if m . group ( '<STR_LIT:type>' ) == '<STR_LIT>' : <EOL> video_id = m . group ( '<STR_LIT>' ) <EOL> desktop_url = '<STR_LIT>' + video_id <EOL> return self . url_result ( desktop_url , '<STR_LIT>' ) <EOL> if m . group ( '<STR_LIT:type>' ) == '<STR_LIT>' : <EOL> video_id = m . group ( '<STR_LIT>' ) <EOL> webpage = self . _download_webpage ( url , video_id ) <EOL> desktop_video_id = self . _html_search_regex ( <EOL> r'<STR_LIT>' , webpage , '<STR_LIT>' ) <EOL> desktop_url = '<STR_LIT>' + desktop_video_id <EOL> return self . url_result ( desktop_url , '<STR_LIT>' ) <EOL> video_url = '<STR_LIT>' % video_id <EOL> webpage = self . _download_webpage ( url , video_id ) <EOL> self . report_extraction ( video_id ) <EOL> video_title = self . _html_search_regex ( r'<STR_LIT>' , <EOL> webpage , '<STR_LIT:title>' ) <EOL> uploader = self . _html_search_regex ( r'<STR_LIT>' , <EOL> webpage , '<STR_LIT>' , fatal = False , flags = re . DOTALL ) <EOL> thumbnail = self . _html_search_regex ( r'<STR_LIT>' , <EOL> webpage , '<STR_LIT>' , fatal = False ) <EOL> return { <EOL> '<STR_LIT:id>' : video_id , <EOL> '<STR_LIT:url>' : video_url , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : video_title , <EOL> '<STR_LIT>' : uploader , <EOL> '<STR_LIT>' : thumbnail , <EOL> } <EOL> class UstreamChannelIE ( InfoExtractor ) : <EOL> _VALID_URL = r'<STR_LIT>' <EOL> IE_NAME = '<STR_LIT>' <EOL> _TEST = { <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> def _real_extract ( self , url ) : <EOL> m = re . match ( self . _VALID_URL , url ) <EOL> display_id = m . group ( '<STR_LIT>' ) <EOL> webpage = self . _download_webpage ( url , display_id ) <EOL> channel_id = self . _html_search_meta ( '<STR_LIT>' , webpage ) <EOL> BASE = '<STR_LIT>' <EOL> next_url = '<STR_LIT>' % channel_id <EOL> video_ids = [ ] <EOL> while next_url : <EOL> reply = self . _download_json ( <EOL> compat_urlparse . urljoin ( BASE , next_url ) , display_id , <EOL> note = '<STR_LIT>' % ( len ( video_ids ) + <NUM_LIT:1> ) ) <EOL> video_ids . extend ( re . findall ( r'<STR_LIT>' , reply [ '<STR_LIT:data>' ] ) ) <EOL> next_url = reply [ '<STR_LIT>' ] <EOL> entries = [ <EOL> self . url_result ( '<STR_LIT>' + vid , '<STR_LIT>' ) <EOL> for vid in video_ids ] <EOL> return { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:id>' : channel_id , <EOL> '<STR_LIT>' : display_id , <EOL> '<STR_LIT>' : entries , <EOL> } </s>
