]>
Commit | Line | Data |
---|---|---|
40c716d2 JMF |
1 | from __future__ import unicode_literals |
2 | ||
2ef648d3 | 3 | import re |
2ef648d3 JMF |
4 | |
5 | from .common import InfoExtractor | |
2ef648d3 | 6 | |
a95967f8 | 7 | |
2ef648d3 | 8 | class IGNIE(InfoExtractor): |
a95967f8 JMF |
9 | """ |
10 | Extractor for some of the IGN sites, like www.ign.com, es.ign.com de.ign.com. | |
11 | Some videos of it.ign.com are also supported | |
12 | """ | |
13 | ||
ee6adb16 | 14 | _VALID_URL = r'https?://.+?\.ign\.com/(?P<type>videos|show_videos|articles|(?:[^/]*/feature))(/.+)?/(?P<name_or_id>.+)' |
40c716d2 | 15 | IE_NAME = 'ign.com' |
2ef648d3 | 16 | |
a95967f8 | 17 | _CONFIG_URL_TEMPLATE = 'http://www.ign.com/videos/configs/id/%s.config' |
40c716d2 JMF |
18 | _DESCRIPTION_RE = [ |
19 | r'<span class="page-object-description">(.+?)</span>', | |
20 | r'id="my_show_video">.*?<p>(.*?)</p>', | |
a204c854 | 21 | r'<meta name="description" content="(.*?)"', |
40c716d2 | 22 | ] |
a95967f8 | 23 | |
ee6adb16 JMF |
24 | _TESTS = [ |
25 | { | |
40c716d2 JMF |
26 | 'url': 'http://www.ign.com/videos/2013/06/05/the-last-of-us-review', |
27 | 'md5': 'eac8bdc1890980122c3b66f14bdd02e9', | |
28 | 'info_dict': { | |
29 | 'id': '8f862beef863986b2785559b9e1aa599', | |
30 | 'ext': 'mp4', | |
31 | 'title': 'The Last of Us Review', | |
32 | 'description': 'md5:c8946d4260a4d43a00d5ae8ed998870c', | |
ee6adb16 JMF |
33 | } |
34 | }, | |
35 | { | |
40c716d2 JMF |
36 | 'url': 'http://me.ign.com/en/feature/15775/100-little-things-in-gta-5-that-will-blow-your-mind', |
37 | 'playlist': [ | |
ee6adb16 | 38 | { |
40c716d2 JMF |
39 | 'info_dict': { |
40 | 'id': '5ebbd138523268b93c9141af17bec937', | |
41 | 'ext': 'mp4', | |
42 | 'title': 'GTA 5 Video Review', | |
43 | 'description': 'Rockstar drops the mic on this generation of games. Watch our review of the masterly Grand Theft Auto V.', | |
ee6adb16 JMF |
44 | }, |
45 | }, | |
46 | { | |
40c716d2 JMF |
47 | 'info_dict': { |
48 | 'id': '638672ee848ae4ff108df2a296418ee2', | |
49 | 'ext': 'mp4', | |
50 | 'title': '26 Twisted Moments from GTA 5 in Slow Motion', | |
51 | 'description': 'The twisted beauty of GTA 5 in stunning slow motion.', | |
ee6adb16 JMF |
52 | }, |
53 | }, | |
54 | ], | |
40c716d2 JMF |
55 | 'params': { |
56 | 'skip_download': True, | |
ee6adb16 JMF |
57 | }, |
58 | }, | |
a204c854 JMF |
59 | { |
60 | 'url': 'http://www.ign.com/articles/2014/08/15/rewind-theater-wild-trailer-gamescom-2014?watch', | |
61 | 'md5': '4e9a0bda1e5eebd31ddcf86ec0b9b3c7', | |
62 | 'info_dict': { | |
63 | 'id': '078fdd005f6d3c02f63d795faa1b984f', | |
64 | 'ext': 'mp4', | |
65 | 'title': 'Rewind Theater - Wild Trailer Gamescom 2014', | |
66 | 'description': 'Giant skeletons, bloody hunts, and captivating' | |
67 | ' natural beauty take our breath away.', | |
68 | }, | |
69 | }, | |
ee6adb16 | 70 | ] |
2ef648d3 | 71 | |
a95967f8 | 72 | def _find_video_id(self, webpage): |
40c716d2 | 73 | res_id = [ |
109a540e | 74 | r'"video_id"\s*:\s*"(.*?)"', |
40c716d2 JMF |
75 | r'data-video-id="(.+?)"', |
76 | r'<object id="vid_(.+?)"', | |
77 | r'<meta name="og:image" content=".*/(.+?)-(.+?)/.+.jpg"', | |
a204c854 | 78 | r'class="hero-poster[^"]*?"[^>]*id="(.+?)"', |
40c716d2 | 79 | ] |
a95967f8 JMF |
80 | return self._search_regex(res_id, webpage, 'video id') |
81 | ||
2ef648d3 JMF |
82 | def _real_extract(self, url): |
83 | mobj = re.match(self._VALID_URL, url) | |
a95967f8 | 84 | name_or_id = mobj.group('name_or_id') |
f1fb2d12 | 85 | page_type = mobj.group('type') |
a95967f8 | 86 | webpage = self._download_webpage(url, name_or_id) |
a204c854 | 87 | if page_type != 'video': |
ee6adb16 | 88 | multiple_urls = re.findall( |
109a540e | 89 | '<param name="flashvars"[^>]*value="[^"]*?url=(https?://www\.ign\.com/videos/.*?)["&]', |
ee6adb16 JMF |
90 | webpage) |
91 | if multiple_urls: | |
92 | return [self.url_result(u, ie='IGN') for u in multiple_urls] | |
93 | ||
a95967f8 JMF |
94 | video_id = self._find_video_id(webpage) |
95 | result = self._get_video_info(video_id) | |
96 | description = self._html_search_regex(self._DESCRIPTION_RE, | |
40c716d2 | 97 | webpage, 'video description', flags=re.DOTALL) |
a95967f8 JMF |
98 | result['description'] = description |
99 | return result | |
100 | ||
101 | def _get_video_info(self, video_id): | |
102 | config_url = self._CONFIG_URL_TEMPLATE % video_id | |
40c716d2 | 103 | config = self._download_json(config_url, video_id) |
2ef648d3 | 104 | media = config['playlist']['media'] |
2ef648d3 | 105 | |
40c716d2 JMF |
106 | return { |
107 | 'id': media['metadata']['videoId'], | |
108 | 'url': media['url'], | |
109 | 'title': media['metadata']['title'], | |
110 | 'thumbnail': media['poster'][0]['url'].replace('{size}', 'grande'), | |
111 | } | |
2ef648d3 JMF |
112 | |
113 | ||
a95967f8 | 114 | class OneUPIE(IGNIE): |
c0ade33e | 115 | _VALID_URL = r'https?://gamevideos\.1up\.com/(?P<type>video)/id/(?P<name_or_id>.+)' |
a95967f8 JMF |
116 | IE_NAME = '1up.com' |
117 | ||
118 | _DESCRIPTION_RE = r'<div id="vid_summary">(.+?)</div>' | |
119 | ||
52fadd5f | 120 | _TESTS = [{ |
40c716d2 JMF |
121 | 'url': 'http://gamevideos.1up.com/video/id/34976', |
122 | 'md5': '68a54ce4ebc772e4b71e3123d413163d', | |
123 | 'info_dict': { | |
124 | 'id': '34976', | |
125 | 'ext': 'mp4', | |
126 | 'title': 'Sniper Elite V2 - Trailer', | |
127 | 'description': 'md5:5d289b722f5a6d940ca3136e9dae89cf', | |
a95967f8 | 128 | } |
52fadd5f | 129 | }] |
ee6adb16 | 130 | |
a95967f8 JMF |
131 | def _real_extract(self, url): |
132 | mobj = re.match(self._VALID_URL, url) | |
a95967f8 | 133 | result = super(OneUPIE, self)._real_extract(url) |
40c716d2 | 134 | result['id'] = mobj.group('name_or_id') |
a95967f8 | 135 | return result |