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