Add IGNIE
[youtube-dl] / youtube_dl / extractor / ign.py
1 import re
2 import json
3
4 from .common import InfoExtractor
5 from ..utils import (
6     determine_ext,
7 )
8
9 class IGNIE(InfoExtractor):
10     _VALID_URL = r'http://www.ign.com/videos/.+/(?P<name>.+)'
11     IE_NAME = u'ign.com'
12
13     _TEST = {
14         u'url': u'http://www.ign.com/videos/2013/06/05/the-last-of-us-review',
15         u'file': u'8f862beef863986b2785559b9e1aa599.mp4',
16         u'md5': u'eac8bdc1890980122c3b66f14bdd02e9',
17         u'info_dict': {
18             u'title': u'The Last of Us Review',
19             u'description': u'md5:c8946d4260a4d43a00d5ae8ed998870c',
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         name = mobj.group('name')
26         config_url = url + '.config'
27         webpage = self._download_webpage(url, name)
28         config = json.loads(self._download_webpage(config_url, name, u'Downloading video info'))
29
30         self.report_extraction(name)
31         description = self._html_search_regex(r'<span class="page-object-description">(.+?)</span>',
32                                               webpage, 'video description', flags=re.DOTALL)
33         media = config['playlist']['media']
34         video_url = media['url']
35
36         return {'id': media['metadata']['videoId'],
37                 'url': video_url,
38                 'ext': determine_ext(video_url),
39                 'title': media['metadata']['title'],
40                 'description': description,
41                 'thumbnail': media['poster'][0]['url'].replace('{size}', 'small'),
42                 }
43         
44
45