]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ooyala.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
12 class OoyalaIE(InfoExtractor
):
13 _VALID_URL
= r
'(?:ooyala:|https?://.+?\.ooyala\.com/.*?(?:embedCode|ec)=)(?P<id>.+?)(&|$)'
17 # From http://it.slashdot.org/story/13/04/25/178216/recovering-data-from-broken-hard-drives-and-ssds-video
18 'url': 'http://player.ooyala.com/player.js?embedCode=pxczE2YjpfHfn1f3M-ykG_AmJRRn0PD8',
19 'md5': '3f5cceb3a7bf461d6c29dc466cf8033c',
21 'id': 'pxczE2YjpfHfn1f3M-ykG_AmJRRn0PD8',
23 'title': 'Explaining Data Recovery from Hard Drives and SSDs',
24 'description': 'How badly damaged does a drive have to be to defeat Russell and his crew? Apparently, smashed to bits.',
27 # Only available for ipad
28 'url': 'http://player.ooyala.com/player.js?embedCode=x1b3lqZDq9y_7kMyC2Op5qo-p077tXD0',
29 'md5': '4b9754921fddb68106e48c142e2a01e6',
31 'id': 'x1b3lqZDq9y_7kMyC2Op5qo-p077tXD0',
33 'title': 'Simulation Overview - Levels of Simulation',
40 def _url_for_embed_code(embed_code
):
41 return 'http://player.ooyala.com/player.js?embedCode=%s' % embed_code
44 def _build_url_result(cls
, embed_code
):
45 return cls
.url_result(cls
._url
_for
_embed
_code
(embed_code
),
48 def _extract_result(self
, info
, more_info
):
50 'id': info
['embedCode'],
52 'title': unescapeHTML(info
['title']),
53 'url': info
.get('ipad_url') or info
['url'],
54 'description': unescapeHTML(more_info
['description']),
55 'thumbnail': more_info
['promo'],
58 def _real_extract(self
, url
):
59 mobj
= re
.match(self
._VALID
_URL
, url
)
60 embedCode
= mobj
.group('id')
61 player_url
= 'http://player.ooyala.com/player.js?embedCode=%s' % embedCode
62 player
= self
._download
_webpage
(player_url
, embedCode
)
63 mobile_url
= self
._search
_regex
(r
'mobile_player_url="(.+?)&device="',
64 player
, 'mobile player url')
65 # Looks like some videos are only available for particular devices
66 # (e.g. http://player.ooyala.com/player.js?embedCode=x1b3lqZDq9y_7kMyC2Op5qo-p077tXD0
67 # is only available for ipad)
68 # Working around with fetching URLs for all the devices found starting with 'unknown'
69 # until we succeed or eventually fail for each device.
70 devices
= re
.findall(r
'device\s*=\s*"([^"]+)";', player
)
71 devices
.remove('unknown')
72 devices
.insert(0, 'unknown')
73 for device
in devices
:
74 mobile_player
= self
._download
_webpage
(
75 '%s&device=%s' % (mobile_url
, device
), embedCode
,
76 'Downloading mobile player JS for %s device' % device
)
77 videos_info
= self
._search
_regex
(
78 r
'var streams=window.oo_testEnv\?\[\]:eval\("\((\[{.*?}\])\)"\);',
79 mobile_player
, 'info', fatal
=False, default
=None)
83 raise ExtractorError('Unable to extract info')
84 videos_info
= videos_info
.replace('\\"', '"')
85 videos_more_info
= self
._search
_regex
(
86 r
'eval\("\(({.*?\\"promo\\".*?})\)"', mobile_player
, 'more info').replace('\\"', '"')
87 videos_info
= json
.loads(videos_info
)
88 videos_more_info
= json
.loads(videos_more_info
)
90 if videos_more_info
.get('lineup'):
91 videos
= [self
._extract
_result
(info
, more_info
) for (info
, more_info
) in zip(videos_info
, videos_more_info
['lineup'])]
95 'title': unescapeHTML(videos_more_info
['title']),
99 return self
._extract
_result
(videos_info
[0], videos_more_info
)