]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ooyala.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
   6 from ..utils 
import unescapeHTML
 
   9 class OoyalaIE(InfoExtractor
): 
  10     _VALID_URL 
= r
'(?:ooyala:|https?://.+?\.ooyala\.com/.*?(?:embedCode|ec)=)(?P<id>.+?)(&|$)' 
  13         # From http://it.slashdot.org/story/13/04/25/178216/recovering-data-from-broken-hard-drives-and-ssds-video 
  14         'url': 'http://player.ooyala.com/player.js?embedCode=pxczE2YjpfHfn1f3M-ykG_AmJRRn0PD8', 
  15         'md5': '3f5cceb3a7bf461d6c29dc466cf8033c', 
  17             'id': 'pxczE2YjpfHfn1f3M-ykG_AmJRRn0PD8', 
  19             'title': 'Explaining Data Recovery from Hard Drives and SSDs', 
  20             'description': 'How badly damaged does a drive have to be to defeat Russell and his crew? Apparently, smashed to bits.', 
  25     def _url_for_embed_code(embed_code
): 
  26         return 'http://player.ooyala.com/player.js?embedCode=%s' % embed_code
 
  29     def _build_url_result(cls
, embed_code
): 
  30         return cls
.url_result(cls
._url
_for
_embed
_code
(embed_code
), 
  33     def _extract_result(self
, info
, more_info
): 
  35             'id': info
['embedCode'], 
  37             'title': unescapeHTML(info
['title']), 
  38             'url': info
.get('ipad_url') or info
['url'], 
  39             'description': unescapeHTML(more_info
['description']), 
  40             'thumbnail': more_info
['promo'], 
  43     def _real_extract(self
, url
): 
  44         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  45         embedCode 
= mobj
.group('id') 
  46         player_url 
= 'http://player.ooyala.com/player.js?embedCode=%s' % embedCode
 
  47         player 
= self
._download
_webpage
(player_url
, embedCode
) 
  48         mobile_url 
= self
._search
_regex
(r
'mobile_player_url="(.+?)&device="', 
  49                                         player
, 'mobile player url') 
  50         mobile_player 
= self
._download
_webpage
(mobile_url
, embedCode
) 
  51         videos_info 
= self
._search
_regex
( 
  52             r
'var streams=window.oo_testEnv\?\[\]:eval\("\((\[{.*?}\])\)"\);', 
  53             mobile_player
, 'info').replace('\\"','"') 
  54         videos_more_info 
= self
._search
_regex
(r
'eval\("\(({.*?\\"promo\\".*?})\)"', mobile_player
, 'more info').replace('\\"','"') 
  55         videos_info 
= json
.loads(videos_info
) 
  56         videos_more_info 
=json
.loads(videos_more_info
) 
  58         if videos_more_info
.get('lineup'): 
  59             videos 
= [self
._extract
_result
(info
, more_info
) for (info
, more_info
) in zip(videos_info
, videos_more_info
['lineup'])] 
  63                 'title': unescapeHTML(videos_more_info
['title']), 
  67             return self
._extract
_result
(videos_info
[0], videos_more_info
)