cloudy.py 1.8 KB

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