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 u
'url': u
'http://www.gametrailers.com/videos/zbvr8i/mirror-s-edge-2-e3-2013--debut-trailer',
14 u
'file': u
'zbvr8i.flv',
15 u
'md5': u
'c3edbc995ab4081976e16779bd96a878',
17 u
"title": u
"E3 2013: Debut Trailer"
19 u
'skip': u
'Requires rtmpdump'
22 def _real_extract(self
, url
):
23 mobj
= re
.match(self
._VALID
_URL
, url
)
25 raise ExtractorError(u
'Invalid URL: %s' % url
)
26 video_id
= mobj
.group('id')
27 video_type
= mobj
.group('type')
28 webpage
= self
._download
_webpage
(url
, video_id
)
29 if video_type
== 'full-episodes':
30 mgid_re
= r
'data-video="(?P<mgid>mgid:.*?)"'
32 mgid_re
= r
'data-contentId=\'(?P
<mgid
>mgid
:.*?
)\''
33 mgid = self._search_regex(mgid_re, webpage, u'mgid
')
34 data = compat_urllib_parse.urlencode({'uri
': mgid, 'acceptMethods
': 'fms
'})
36 info_page = self._download_webpage('http
://www
.gametrailers
.com
/feeds
/mrss?
' + data,
37 video_id, u'Downloading video info
')
38 links_webpage = self._download_webpage('http
://www
.gametrailers
.com
/feeds
/mediagen
/?
' + data,
39 video_id, u'Downloading video urls info
')
41 self.report_extraction(video_id)
42 info_re = r'''<title><!\[CDATA\[(?P<title>.*?)\]\]></title>.*
43 <description><!\[CDATA\[(?P<description>.*?)\]\]></description>.*
45 <url>(?P<thumb>.*?)</url>.*
48 m_info = re.search(info_re, info_page, re.VERBOSE|re.DOTALL)
50 raise ExtractorError(u'Unable to extract video info
')
51 video_title = m_info.group('title
')
52 video_description = m_info.group('description
')
53 video_thumb = m_info.group('thumb
')
55 m_urls = list(re.finditer(r'<src
>(?P
<url
>.*)</src
>', links_webpage))
56 if m_urls is None or len(m_urls) == 0:
57 raise ExtractorError(u'Unable to extract video url
')
58 # They are sorted from worst to best quality
59 video_url = m_urls[-1].group('url
')
61 return {'url
': video_url,
64 # Videos are actually flv not mp4
66 'thumbnail
': video_thumb,
67 'description
': video_description,