3 from .common
import InfoExtractor
10 class GametrailersIE(InfoExtractor
):
11 _VALID_URL
= r
'http://www.gametrailers.com/(?P<type>videos|reviews|full-episodes)/(?P<id>.*?)/(?P<title>.*)'
13 def _real_extract(self
, url
):
14 mobj
= re
.match(self
._VALID
_URL
, url
)
16 raise ExtractorError(u
'Invalid URL: %s' % url
)
17 video_id
= mobj
.group('id')
18 video_type
= mobj
.group('type')
19 webpage
= self
._download
_webpage
(url
, video_id
)
20 if video_type
== 'full-episodes':
21 mgid_re
= r
'data-video="(?P<mgid>mgid:.*?)"'
23 mgid_re
= r
'data-contentId=\'(?P
<mgid
>mgid
:.*?
)\''
24 mgid = self._search_regex(mgid_re, webpage, u'mgid
')
25 data = compat_urllib_parse.urlencode({'uri
': mgid, 'acceptMethods
': 'fms
'})
27 info_page = self._download_webpage('http
://www
.gametrailers
.com
/feeds
/mrss?
' + data,
28 video_id, u'Downloading video info
')
29 links_webpage = self._download_webpage('http
://www
.gametrailers
.com
/feeds
/mediagen
/?
' + data,
30 video_id, u'Downloading video urls info
')
32 self.report_extraction(video_id)
33 info_re = r'''<title><!\[CDATA\[(?P<title>.*?)\]\]></title>.*
34 <description><!\[CDATA\[(?P<description>.*?)\]\]></description>.*
36 <url>(?P<thumb>.*?)</url>.*
39 m_info = re.search(info_re, info_page, re.VERBOSE|re.DOTALL)
41 raise ExtractorError(u'Unable to extract video info
')
42 video_title = m_info.group('title
')
43 video_description = m_info.group('description
')
44 video_thumb = m_info.group('thumb
')
46 m_urls = list(re.finditer(r'<src
>(?P
<url
>.*)</src
>', links_webpage))
47 if m_urls is None or len(m_urls) == 0:
48 raise ExtractorError(u'Unable to extract video url
')
49 # They are sorted from worst to best quality
50 video_url = m_urls[-1].group('url
')
52 return {'url
': video_url,
55 # Videos are actually flv not mp4
57 'thumbnail
': video_thumb,
58 'description
': video_description,