<s> from __future__ import unicode_literals <EOL> import re <EOL> from . common import InfoExtractor <EOL> from . . utils import ( <EOL> qualities , <EOL> determine_ext , <EOL> ) <EOL> class TeacherTubeIE ( InfoExtractor ) : <EOL> IE_NAME = '<STR_LIT>' <EOL> IE_DESC = '<STR_LIT>' <EOL> _VALID_URL = r'<STR_LIT>' <EOL> _TESTS = [ { <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:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } , { <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:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } , { <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:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } , <EOL> } , { <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:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } , <EOL> } ] <EOL> def _real_extract ( self , url ) : <EOL> video_id = self . _match_id ( url ) <EOL> webpage = self . _download_webpage ( url , video_id ) <EOL> title = self . _html_search_meta ( '<STR_LIT:title>' , webpage , '<STR_LIT:title>' , fatal = True ) <EOL> TITLE_SUFFIX = '<STR_LIT>' <EOL> if title . endswith ( TITLE_SUFFIX ) : <EOL> title = title [ : - len ( TITLE_SUFFIX ) ] . strip ( ) <EOL> description = self . _html_search_meta ( '<STR_LIT:description>' , webpage , '<STR_LIT:description>' ) <EOL> if description : <EOL> description = description . strip ( ) <EOL> quality = qualities ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> media_urls = re . findall ( r'<STR_LIT>' , webpage ) <EOL> media_urls . extend ( re . findall ( r'<STR_LIT>' , webpage ) ) <EOL> media_urls . extend ( re . findall ( r'<STR_LIT>' , webpage ) ) <EOL> formats = [ <EOL> { <EOL> '<STR_LIT:url>' : media_url , <EOL> '<STR_LIT>' : quality ( determine_ext ( media_url ) ) <EOL> } for media_url in set ( media_urls ) <EOL> ] <EOL> self . _sort_formats ( formats ) <EOL> return { <EOL> '<STR_LIT:id>' : video_id , <EOL> '<STR_LIT:title>' : title , <EOL> '<STR_LIT>' : self . _html_search_regex ( r'<STR_LIT>' , webpage , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : formats , <EOL> '<STR_LIT:description>' : description , <EOL> } <EOL> class TeacherTubeUserIE ( InfoExtractor ) : <EOL> IE_NAME = '<STR_LIT>' <EOL> IE_DESC = '<STR_LIT>' <EOL> _VALID_URL = r'<STR_LIT>' <EOL> _MEDIA_RE = r'''<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> mobj = re . match ( self . _VALID_URL , url ) <EOL> user_id = mobj . group ( '<STR_LIT:user>' ) <EOL> urls = [ ] <EOL> webpage = self . _download_webpage ( url , user_id ) <EOL> urls . extend ( re . findall ( self . _MEDIA_RE , webpage ) ) <EOL> pages = re . findall ( r'<STR_LIT>' % user_id , webpage ) [ : - <NUM_LIT:1> ] <EOL> for p in pages : <EOL> more = '<STR_LIT>' % ( user_id , p ) <EOL> webpage = self . _download_webpage ( more , user_id , '<STR_LIT>' % ( p , len ( pages ) ) ) <EOL> video_urls = re . findall ( self . _MEDIA_RE , webpage ) <EOL> urls . extend ( video_urls ) <EOL> entries = [ self . url_result ( vurl , '<STR_LIT>' ) for vurl in urls ] <EOL> return self . playlist_result ( entries , user_id ) </s>
