]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ign.py
c80185b535b8d9853adf886fb8b5582284d12a03
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
   8 class IGNIE(InfoExtractor
): 
  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 
  14     _VALID_URL 
= r
'https?://.+?\.ign\.com/(?P<type>videos|show_videos|articles|(?:[^/]*/feature))(/.+)?/(?P<name_or_id>.+)' 
  17     _CONFIG_URL_TEMPLATE 
= 'http://www.ign.com/videos/configs/id/%s.config' 
  19         r
'<span class="page-object-description">(.+?)</span>', 
  20         r
'id="my_show_video">.*?<p>(.*?)</p>', 
  21         r
'<meta name="description" content="(.*?)"', 
  26             'url': 'http://www.ign.com/videos/2013/06/05/the-last-of-us-review', 
  27             'md5': 'eac8bdc1890980122c3b66f14bdd02e9', 
  29                 'id': '8f862beef863986b2785559b9e1aa599', 
  31                 'title': 'The Last of Us Review', 
  32                 'description': 'md5:c8946d4260a4d43a00d5ae8ed998870c', 
  36             'url': 'http://me.ign.com/en/feature/15775/100-little-things-in-gta-5-that-will-blow-your-mind', 
  40                         'id': '5ebbd138523268b93c9141af17bec937', 
  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.', 
  48                         'id': '638672ee848ae4ff108df2a296418ee2', 
  50                         'title': '26 Twisted Moments from GTA 5 in Slow Motion', 
  51                         'description': 'The twisted beauty of GTA 5 in stunning slow motion.', 
  56                 'skip_download': True, 
  60             'url': 'http://www.ign.com/articles/2014/08/15/rewind-theater-wild-trailer-gamescom-2014?watch', 
  61             'md5': '4e9a0bda1e5eebd31ddcf86ec0b9b3c7', 
  63                 'id': '078fdd005f6d3c02f63d795faa1b984f', 
  65                 'title': 'Rewind Theater - Wild Trailer Gamescom 2014', 
  66                 'description': 'Giant skeletons, bloody hunts, and captivating' 
  67                     ' natural beauty take our breath away.', 
  72     def _find_video_id(self
, webpage
): 
  74             r
'"video_id"\s*:\s*"(.*?)"', 
  75             r
'data-video-id="(.+?)"', 
  76             r
'<object id="vid_(.+?)"', 
  77             r
'<meta name="og:image" content=".*/(.+?)-(.+?)/.+.jpg"', 
  78             r
'class="hero-poster[^"]*?"[^>]*id="(.+?)"', 
  80         return self
._search
_regex
(res_id
, webpage
, 'video id') 
  82     def _real_extract(self
, url
): 
  83         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  84         name_or_id 
= mobj
.group('name_or_id') 
  85         page_type 
= mobj
.group('type') 
  86         webpage 
= self
._download
_webpage
(url
, name_or_id
) 
  87         if page_type 
!= 'video': 
  88             multiple_urls 
= re
.findall( 
  89                 '<param name="flashvars"[^>]*value="[^"]*?url=(https?://www\.ign\.com/videos/.*?)["&]', 
  92                 entries 
= [self
.url_result(u
, ie
='IGN') for u 
in multiple_urls
] 
  99         video_id 
= self
._find
_video
_id
(webpage
) 
 100         result 
= self
._get
_video
_info
(video_id
) 
 101         description 
= self
._html
_search
_regex
(self
._DESCRIPTION
_RE
, 
 102             webpage
, 'video description', flags
=re
.DOTALL
) 
 103         result
['description'] = description
 
 106     def _get_video_info(self
, video_id
): 
 107         config_url 
= self
._CONFIG
_URL
_TEMPLATE 
% video_id
 
 108         config 
= self
._download
_json
(config_url
, video_id
) 
 109         media 
= config
['playlist']['media'] 
 112             'id': media
['metadata']['videoId'], 
 114             'title': media
['metadata']['title'], 
 115             'thumbnail': media
['poster'][0]['url'].replace('{size}', 'grande'), 
 119 class OneUPIE(IGNIE
): 
 120     _VALID_URL 
= r
'https?://gamevideos\.1up\.com/(?P<type>video)/id/(?P<name_or_id>.+)\.html' 
 123     _DESCRIPTION_RE 
= r
'<div id="vid_summary">(.+?)</div>' 
 126         'url': 'http://gamevideos.1up.com/video/id/34976.html', 
 127         'md5': '68a54ce4ebc772e4b71e3123d413163d', 
 131             'title': 'Sniper Elite V2 - Trailer', 
 132             'description': 'md5:5d289b722f5a6d940ca3136e9dae89cf', 
 136     def _real_extract(self
, url
): 
 137         mobj 
= re
.match(self
._VALID
_URL
, url
) 
 138         result 
= super(OneUPIE
, self
)._real
_extract
(url
) 
 139         result
['id'] = mobj
.group('name_or_id')