]> git.bitcoin.ninja Git - youtube-dl/commitdiff
Add GametrailersIE
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 16 Jun 2013 18:34:45 +0000 (20:34 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 16 Jun 2013 18:34:45 +0000 (20:34 +0200)
test/tests.json
youtube_dl/InfoExtractors.py

index 6c2373321de68e33fb14dff4b8b5cef801697b44..a2181bccc490e2dc4d738a22fff04a7fc1d651b0 100644 (file)
     "info_dict":{
       "title":"Смях! Чудо - чист за секунди - Скрита камера"
     }
+  },
+  {
+    "name": "Gametrailers",
+    "url": "http://www.gametrailers.com/videos/zbvr8i/mirror-s-edge-2-e3-2013--debut-trailer",
+    "file": "zbvr8i.flv",
+    "md5": "c3edbc995ab4081976e16779bd96a878",
+    "info_dict": {
+        "title": "E3 2013: Debut Trailer"
+    },
+    "skip": "Requires rtmpdump"
   }
 ]
index 33ba0fdd1be218ae0a5e04348545defeb407b386..6904a6686d8b6e5ab7dfe7c4bee59634df67f201 100755 (executable)
@@ -4629,6 +4629,60 @@ class Vbox7IE(InfoExtractor):
             'thumbnail': thumbnail_url,
         }]
 
+class GametrailersIE(InfoExtractor):
+    _VALID_URL = r'http://www.gametrailers.com/(?P<type>videos|reviews|full-episodes)/(?P<id>.*?)/(?P<title>.*)'
+
+    def _real_extract(self, url):
+        mobj = re.match(self._VALID_URL, url)
+        if mobj is None:
+            raise ExtractorError(u'Invalid URL: %s' % url)
+        video_id = mobj.group('id')
+        video_type = mobj.group('type')
+        webpage = self._download_webpage(url, video_id)
+        if video_type == 'full-episodes':
+            mgid_re = r'data-video="(?P<mgid>mgid:.*?)"'
+        else:
+            mgid_re = r'data-contentId=\'(?P<mgid>mgid:.*?)\''
+        m_mgid = re.search(mgid_re, webpage)
+        if m_mgid is None:
+            raise ExtractorError(u'Unable to extract mgid')
+        mgid = m_mgid.group(1)
+        data = compat_urllib_parse.urlencode({'uri': mgid, 'acceptMethods': 'fms'})
+
+        info_page = self._download_webpage('http://www.gametrailers.com/feeds/mrss?' + data,
+                                           video_id, u'Downloading video info')
+        links_webpage = self._download_webpage('http://www.gametrailers.com/feeds/mediagen/?' + data,
+                                               video_id, u'Downloading video urls info')
+
+        self.report_extraction(video_id)
+        info_re = r'''<title><!\[CDATA\[(?P<title>.*?)\]\]></title>.*
+                      <description><!\[CDATA\[(?P<description>.*?)\]\]></description>.*
+                      <image>.*
+                        <url>(?P<thumb>.*?)</url>.*
+                      </image>'''
+
+        m_info = re.search(info_re, info_page, re.VERBOSE|re.DOTALL)
+        if m_info is None:
+            raise ExtractorError(u'Unable to extract video info')
+        video_title = m_info.group('title')
+        video_description = m_info.group('description')
+        video_thumb = m_info.group('thumb')
+
+        m_urls = re.finditer(r'<src>(?P<url>.*)</src>', links_webpage)
+        if m_urls is None:
+            raise ExtractError(u'Unable to extrat video url')
+        # They are sorted from worst to best quality
+        video_url = list(m_urls)[-1].group('url')
+
+        return {'url':         video_url,
+                'id':          video_id,
+                'title':       video_title,
+                # Videos are actually flv not mp4
+                'ext':         'flv',
+                'thumbnail':   video_thumb,
+                'description': video_description,
+                }
+
 def gen_extractors():
     """ Return a list of an instance of every supported extractor.
     The order does matter; the first extractor matched is the one handling the URL.
@@ -4694,6 +4748,7 @@ def gen_extractors():
         XHamsterIE(),
         HypemIE(),
         Vbox7IE(),
+        GametrailersIE(),
         GenericIE()
     ]