]>
 
 
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gametrailers.py 
 
 
 
 
 
 
 
 
   1  from  __future__ 
import  unicode_literals
 
   3  from  . common 
import  InfoExtractor
 
  11  class  GametrailersIE ( InfoExtractor
):  
  12      _VALID_URL 
=  r
'http://www\.gametrailers\.com/videos/view/[^/]+/(?P<id>.+)'  
  15          'url' :  'http://www.gametrailers.com/videos/view/gametrailers-com/116437-Just-Cause-3-Review' ,  
  16          'md5' :  'f28c4efa0bdfaf9b760f6507955b6a6a' ,  
  20              'display_id' :  '116437-Just-Cause-3-Review' ,  
  21              'title' :  'Just Cause 3 - Review' ,  
  22              'description' :  'It \' s a lot of fun to shoot at things and then watch them explode in Just Cause 3, but should there be more to the experience than that?' ,  
  26      def  _real_extract ( self
,  url
):  
  27          display_id 
=  self
._ match
_ id
( url
)  
  28          webpage 
=  self
._ download
_ webpage
( url
,  display_id
)  
  29          title 
=  self
._ html
_ search
_ regex
(  
  30              r
'<title>(.+?)\|' ,  webpage
,  'title' ). strip ()  
  31          embed_url 
=  self
._ proto
_ relative
_u rl
(  
  33                  r
'src=\' (// embed
. gametrailers
. com
/ embed
/[ ^
\' ]+) \' ', webpage,  
  36          video_id = url_basename(embed_url)  
  37          embed_page = self._download_webpage(embed_url, video_id)  
  38          embed_vars_json = self._search_regex(  
  39              r' ( ?s
) var embedVars 
= ( \
{.* ?\
}) \s
*</ script
> ', embed_page,  
  41          info = self._parse_json(embed_vars_json, video_id)  
  44          for media in info[' media
']:  
  45              if media[' mediaPurpose
'] == ' play
':  
  48                      ' height
': media[' height
'],  
  49                      ' width
: ': media[' width
'],  
  51          self._sort_formats(formats)  
  55              ' display_id
': display_id,  
  58              ' thumbnail
': info.get(' thumbUri
'),  
  59              ' description
': self._og_search_description(webpage),  
  60              ' duration
': int_or_none(info.get(' videoLengthInSeconds
')),  
  61              ' age_limit
': parse_age_limit(info.get(' audienceRating
')),