]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cloudy.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
17 class CloudyIE(InfoExtractor
):
18 _IE_DESC
= 'cloudy.ec and videoraj.ch'
20 https?://(?:www\.)?(?P<host>cloudy\.ec|videoraj\.ch)/
21 (?:v/|embed\.php\?id=)
24 _EMBED_URL
= 'http://www.%s/embed.php?id=%s'
25 _API_URL
= 'http://www.%s/api/player.api.php?%s'
29 'url': 'https://www.cloudy.ec/v/af511e2527aac',
30 'md5': '5cb253ace826a42f35b4740539bedf07',
32 'id': 'af511e2527aac',
34 'title': 'Funny Cats and Animals Compilation june 2013',
38 'url': 'http://www.videoraj.ch/v/47f399fd8bb60',
39 'md5': '7d0f8799d91efd4eda26587421c3c3b0',
41 'id': '47f399fd8bb60',
43 'title': 'Burning a New iPhone 5 with Gasoline - Will it Survive?',
48 def _extract_video(self
, video_host
, video_id
, file_key
, error_url
=None, try_num
=0):
50 if try_num
> self
._MAX
_TRIES
- 1:
51 raise ExtractorError('Unable to extract video URL', expected
=True)
60 'numOfErrors': try_num
,
62 'errorUrl': error_url
,
65 data_url
= self
._API
_URL
% (video_host
, compat_urllib_parse
.urlencode(form
))
66 player_data
= self
._download
_webpage
(
67 data_url
, video_id
, 'Downloading player data')
68 data
= compat_parse_qs(player_data
)
74 '%s error: %s' % (self
.IE_NAME
, ' '.join(data
['error_msg'])),
77 title
= data
.get('title', [None])[0]
79 title
= remove_end(title
, '&asdasdas').strip()
81 video_url
= data
.get('url', [None])[0]
85 self
._request
_webpage
(HEADRequest(video_url
), video_id
, 'Checking video URL')
86 except ExtractorError
as e
:
87 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
in [404, 410]:
88 self
.report_warning('Invalid video URL, requesting another', video_id
)
89 return self
._extract
_video
(video_host
, video_id
, file_key
, video_url
, try_num
)
97 def _real_extract(self
, url
):
98 mobj
= re
.match(self
._VALID
_URL
, url
)
99 video_host
= mobj
.group('host')
100 video_id
= mobj
.group('id')
102 url
= self
._EMBED
_URL
% (video_host
, video_id
)
103 webpage
= self
._download
_webpage
(url
, video_id
)
105 file_key
= self
._search
_regex
(
106 r
'filekey\s*=\s*"([^"]+)"', webpage
, 'file_key')
108 return self
._extract
_video
(video_host
, video_id
, file_key
)