]>
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)(/.+)?/(?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>',
25 u
'url': u
'http://www.ign.com/videos/2013/06/05/the-last-of-us-review',
26 u
'file': u
'8f862beef863986b2785559b9e1aa599.mp4',
27 u
'md5': u
'eac8bdc1890980122c3b66f14bdd02e9',
29 u
'title': u
'The Last of Us Review',
30 u
'description': u
'md5:c8946d4260a4d43a00d5ae8ed998870c',
34 def _find_video_id(self
, webpage
):
35 res_id
= [r
'data-video-id="(.+?)"',
36 r
'<object id="vid_(.+?)"',
37 r
'<meta name="og:image" content=".*/(.+?)-(.+?)/.+.jpg"',
39 return self
._search
_regex
(res_id
, webpage
, 'video id')
41 def _real_extract(self
, url
):
42 mobj
= re
.match(self
._VALID
_URL
, url
)
43 name_or_id
= mobj
.group('name_or_id')
44 page_type
= mobj
.group('type')
45 webpage
= self
._download
_webpage
(url
, name_or_id
)
46 if page_type
== 'articles':
47 video_url
= self
._search
_regex
(r
'var videoUrl = "(.+?)"', webpage
, u
'video url')
48 return self
.url_result(video_url
, ie
='IGN')
49 video_id
= self
._find
_video
_id
(webpage
)
50 result
= self
._get
_video
_info
(video_id
)
51 description
= self
._html
_search
_regex
(self
._DESCRIPTION
_RE
,
52 webpage
, 'video description',
54 result
['description'] = description
57 def _get_video_info(self
, video_id
):
58 config_url
= self
._CONFIG
_URL
_TEMPLATE
% video_id
59 config
= json
.loads(self
._download
_webpage
(config_url
, video_id
,
60 u
'Downloading video info'))
61 media
= config
['playlist']['media']
62 video_url
= media
['url']
64 return {'id': media
['metadata']['videoId'],
66 'ext': determine_ext(video_url
),
67 'title': media
['metadata']['title'],
68 'thumbnail': media
['poster'][0]['url'].replace('{size}', 'grande'),
73 """Extractor for 1up.com, it uses the ign videos system."""
75 _VALID_URL
= r
'https?://gamevideos.1up.com/(?P<type>video)/id/(?P<name_or_id>.+)'
78 _DESCRIPTION_RE
= r
'<div id="vid_summary">(.+?)</div>'
81 u
'url': u
'http://gamevideos.1up.com/video/id/34976',
82 u
'file': u
'34976.mp4',
83 u
'md5': u
'68a54ce4ebc772e4b71e3123d413163d',
85 u
'title': u
'Sniper Elite V2 - Trailer',
86 u
'description': u
'md5:5d289b722f5a6d940ca3136e9dae89cf',
90 def _real_extract(self
, url
):
91 mobj
= re
.match(self
._VALID
_URL
, url
)
92 id = mobj
.group('name_or_id')
93 result
= super(OneUPIE
, self
)._real
_extract
(url
)