]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cloudy.py
9bc8dbea449509cf275d10470d6e01f337288a21
[youtubedl] / youtube_dl / extractor / cloudy.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 str_to_int,
7 unified_strdate,
8 )
9
10
11 class CloudyIE(InfoExtractor):
12 _IE_DESC = 'cloudy.ec'
13 _VALID_URL = r'https?://(?:www\.)?cloudy\.ec/(?:v/|embed\.php\?.*?\bid=)(?P<id>[A-Za-z0-9]+)'
14 _TESTS = [{
15 'url': 'https://www.cloudy.ec/v/af511e2527aac',
16 'md5': '29832b05028ead1b58be86bf319397ca',
17 'info_dict': {
18 'id': 'af511e2527aac',
19 'ext': 'mp4',
20 'title': 'Funny Cats and Animals Compilation june 2013',
21 'upload_date': '20130913',
22 'view_count': int,
23 }
24 }, {
25 'url': 'http://www.cloudy.ec/embed.php?autoplay=1&id=af511e2527aac',
26 'only_matching': True,
27 }]
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31
32 webpage = self._download_webpage(
33 'http://www.cloudy.ec/embed.php?id=%s' % video_id, video_id)
34
35 info = self._parse_html5_media_entries(url, webpage, video_id)[0]
36
37 webpage = self._download_webpage(
38 'https://www.cloudy.ec/v/%s' % video_id, video_id, fatal=False)
39
40 if webpage:
41 info.update({
42 'title': self._search_regex(
43 r'<h\d[^>]*>([^<]+)<', webpage, 'title'),
44 'upload_date': unified_strdate(self._search_regex(
45 r'>Published at (\d{4}-\d{1,2}-\d{1,2})', webpage,
46 'upload date', fatal=False)),
47 'view_count': str_to_int(self._search_regex(
48 r'([\d,.]+) views<', webpage, 'view count', fatal=False)),
49 })
50
51 if not info.get('title'):
52 info['title'] = video_id
53
54 info['id'] = video_id
55
56 return info