<s> from __future__ import unicode_literals <EOL> import json <EOL> import re <EOL> from . common import InfoExtractor <EOL> from . . utils import ( <EOL> ExtractorError , <EOL> smuggle_url , <EOL> ) <EOL> class MinistryGridIE ( InfoExtractor ) : <EOL> _VALID_URL = r'<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:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <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> webpage = self . _download_webpage ( url , video_id ) <EOL> portlets_json = self . _search_regex ( <EOL> r'<STR_LIT>' , webpage , '<STR_LIT>' ) <EOL> portlets = json . loads ( portlets_json ) <EOL> pl_id = self . _search_regex ( <EOL> r'<STR_LIT>' , webpage , '<STR_LIT>' ) <EOL> for i , portlet in enumerate ( portlets ) : <EOL> portlet_url = '<STR_LIT>' % ( pl_id , portlet ) <EOL> portlet_code = self . _download_webpage ( <EOL> portlet_url , video_id , <EOL> note = '<STR_LIT>' % ( portlet , i + <NUM_LIT:1> , len ( portlets ) ) , <EOL> fatal = False ) <EOL> video_iframe_url = self . _search_regex ( <EOL> r'<STR_LIT>' , portlet_code , '<STR_LIT>' , <EOL> default = None ) <EOL> if video_iframe_url : <EOL> surl = smuggle_url ( <EOL> video_iframe_url , { '<STR_LIT>' : video_id } ) <EOL> return { <EOL> '<STR_LIT>' : '<STR_LIT:url>' , <EOL> '<STR_LIT:id>' : video_id , <EOL> '<STR_LIT:url>' : surl , <EOL> } <EOL> raise ExtractorError ( '<STR_LIT>' ) </s>
