]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/cloudy.py
[redbulltv] Add support for new redbull.com TV URLs(closes #22037)(closes #22063)
[youtube-dl] / 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             'https://www.cloudy.ec/embed.php', video_id, query={
34                 'id': video_id,
35                 'playerPage': 1,
36                 'autoplay': 1,
37             })
38
39         info = self._parse_html5_media_entries(url, webpage, video_id)[0]
40
41         webpage = self._download_webpage(
42             'https://www.cloudy.ec/v/%s' % video_id, video_id, fatal=False)
43
44         if webpage:
45             info.update({
46                 'title': self._search_regex(
47                     r'<h\d[^>]*>([^<]+)<', webpage, 'title'),
48                 'upload_date': unified_strdate(self._search_regex(
49                     r'>Published at (\d{4}-\d{1,2}-\d{1,2})', webpage,
50                     'upload date', fatal=False)),
51                 'view_count': str_to_int(self._search_regex(
52                     r'([\d,.]+) views<', webpage, 'view count', fatal=False)),
53             })
54
55         if not info.get('title'):
56             info['title'] = video_id
57
58         info['id'] = video_id
59
60         return info