]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cloudy.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
18 class CloudyIE(InfoExtractor
):
19 _IE_DESC
= 'cloudy.ec'
21 https?://(?:www\.)?cloudy\.ec/
22 (?:v/|embed\.php\?id=)
25 _EMBED_URL
= 'http://www.cloudy.ec/embed.php?id=%s'
26 _API_URL
= 'http://www.cloudy.ec/api/player.api.php'
29 'url': 'https://www.cloudy.ec/v/af511e2527aac',
30 'md5': '5cb253ace826a42f35b4740539bedf07',
32 'id': 'af511e2527aac',
34 'title': 'Funny Cats and Animals Compilation june 2013',
38 def _extract_video(self
, video_id
, file_key
, error_url
=None, try_num
=0):
40 if try_num
> self
._MAX
_TRIES
- 1:
41 raise ExtractorError('Unable to extract video URL', expected
=True)
50 'numOfErrors': try_num
,
52 'errorUrl': error_url
,
55 player_data
= self
._download
_webpage
(
56 self
._API
_URL
, video_id
, 'Downloading player data', query
=form
)
57 data
= compat_parse_qs(player_data
)
63 '%s error: %s' % (self
.IE_NAME
, ' '.join(data
['error_msg'])),
66 title
= data
.get('title', [None])[0]
68 title
= remove_end(title
, '&asdasdas').strip()
70 video_url
= data
.get('url', [None])[0]
74 self
._request
_webpage
(HEADRequest(video_url
), video_id
, 'Checking video URL')
75 except ExtractorError
as e
:
76 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
in [404, 410]:
77 self
.report_warning('Invalid video URL, requesting another', video_id
)
78 return self
._extract
_video
(video_id
, file_key
, video_url
, try_num
)
86 def _real_extract(self
, url
):
87 mobj
= re
.match(self
._VALID
_URL
, url
)
88 video_id
= mobj
.group('id')
90 url
= self
._EMBED
_URL
% video_id
91 webpage
= self
._download
_webpage
(url
, video_id
)
93 file_key
= self
._search
_regex
(
94 [r
'key\s*:\s*"([^"]+)"', r
'filekey\s*=\s*"([^"]+)"'],
97 return self
._extract
_video
(video_id
, file_key
)