]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ign.py
4 from .common
import InfoExtractor
10 class IGNIE(InfoExtractor
):
12 Extractor for some of the IGN sites, like www.ign.com, es.ign.com de.ign.com.
13 Some videos of it.ign.com are also supported
16 _VALID_URL
= r
'https?://.+?\.ign\.com/(?P<type>videos|show_videos|articles|(?:[^/]*/feature))(/.+)?/(?P<name_or_id>.+)'
19 _CONFIG_URL_TEMPLATE
= 'http://www.ign.com/videos/configs/id/%s.config'
20 _DESCRIPTION_RE
= [r
'<span class="page-object-description">(.+?)</span>',
21 r
'id="my_show_video">.*?<p>(.*?)</p>',
26 u
'url': u
'http://www.ign.com/videos/2013/06/05/the-last-of-us-review',
27 u
'file': u
'8f862beef863986b2785559b9e1aa599.mp4',
28 u
'md5': u
'eac8bdc1890980122c3b66f14bdd02e9',
30 u
'title': u
'The Last of Us Review',
31 u
'description': u
'md5:c8946d4260a4d43a00d5ae8ed998870c',
35 u
'url': u
'http://me.ign.com/en/feature/15775/100-little-things-in-gta-5-that-will-blow-your-mind',
38 u
'file': u
'5ebbd138523268b93c9141af17bec937.mp4',
40 u
'title': u
'GTA 5 Video Review',
41 u
'description': u
'Rockstar drops the mic on this generation of games. Watch our review of the masterly Grand Theft Auto V.',
45 u
'file': u
'638672ee848ae4ff108df2a296418ee2.mp4',
47 u
'title': u
'GTA 5\'s Twisted Beauty in Super Slow Motion',
48 u
'description': u
'The twisted beauty of GTA 5 in stunning slow motion.',
53 u
'skip_download': True,
58 def _find_video_id(self
, webpage
):
59 res_id
= [r
'data-video-id="(.+?)"',
60 r
'<object id="vid_(.+?)"',
61 r
'<meta name="og:image" content=".*/(.+?)-(.+?)/.+.jpg"',
63 return self
._search
_regex
(res_id
, webpage
, 'video id')
65 def _real_extract(self
, url
):
66 mobj
= re
.match(self
._VALID
_URL
, url
)
67 name_or_id
= mobj
.group('name_or_id')
68 page_type
= mobj
.group('type')
69 webpage
= self
._download
_webpage
(url
, name_or_id
)
70 if page_type
== 'articles':
71 video_url
= self
._search
_regex
(r
'var videoUrl = "(.+?)"', webpage
, u
'video url')
72 return self
.url_result(video_url
, ie
='IGN')
73 elif page_type
!= 'video':
74 multiple_urls
= re
.findall(
75 '<param name="flashvars" value="[^"]*?url=(https?://www\.ign\.com/videos/.*?)["&]',
78 return [self
.url_result(u
, ie
='IGN') for u
in multiple_urls
]
80 video_id
= self
._find
_video
_id
(webpage
)
81 result
= self
._get
_video
_info
(video_id
)
82 description
= self
._html
_search
_regex
(self
._DESCRIPTION
_RE
,
83 webpage
, 'video description',
85 result
['description'] = description
88 def _get_video_info(self
, video_id
):
89 config_url
= self
._CONFIG
_URL
_TEMPLATE
% video_id
90 config
= json
.loads(self
._download
_webpage
(config_url
, video_id
,
91 u
'Downloading video info'))
92 media
= config
['playlist']['media']
93 video_url
= media
['url']
95 return {'id': media
['metadata']['videoId'],
97 'ext': determine_ext(video_url
),
98 'title': media
['metadata']['title'],
99 'thumbnail': media
['poster'][0]['url'].replace('{size}', 'grande'),
103 class OneUPIE(IGNIE
):
104 """Extractor for 1up.com, it uses the ign videos system."""
106 _VALID_URL
= r
'https?://gamevideos.1up.com/(?P<type>video)/id/(?P<name_or_id>.+)'
109 _DESCRIPTION_RE
= r
'<div id="vid_summary">(.+?)</div>'
112 u
'url': u
'http://gamevideos.1up.com/video/id/34976',
113 u
'file': u
'34976.mp4',
114 u
'md5': u
'68a54ce4ebc772e4b71e3123d413163d',
116 u
'title': u
'Sniper Elite V2 - Trailer',
117 u
'description': u
'md5:5d289b722f5a6d940ca3136e9dae89cf',
124 def _real_extract(self
, url
):
125 mobj
= re
.match(self
._VALID
_URL
, url
)
126 id = mobj
.group('name_or_id')
127 result
= super(OneUPIE
, self
)._real
_extract
(url
)