logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

clippit.py (2551B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_iso8601,
  6. qualities,
  7. )
  8. import re
  9. class ClippitIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?clippituser\.tv/c/(?P<id>[a-z]+)'
  11. _TEST = {
  12. 'url': 'https://www.clippituser.tv/c/evmgm',
  13. 'md5': '963ae7a59a2ec4572ab8bf2f2d2c5f09',
  14. 'info_dict': {
  15. 'id': 'evmgm',
  16. 'ext': 'mp4',
  17. 'title': 'Bye bye Brutus. #BattleBots - Clippit',
  18. 'uploader': 'lizllove',
  19. 'uploader_url': 'https://www.clippituser.tv/p/lizllove',
  20. 'timestamp': 1472183818,
  21. 'upload_date': '20160826',
  22. 'description': 'BattleBots | ABC',
  23. 'thumbnail': r're:^https?://.*\.jpg$',
  24. }
  25. }
  26. def _real_extract(self, url):
  27. video_id = self._match_id(url)
  28. webpage = self._download_webpage(url, video_id)
  29. title = self._html_search_regex(r'<title.*>(.+?)</title>', webpage, 'title')
  30. FORMATS = ('sd', 'hd')
  31. quality = qualities(FORMATS)
  32. formats = []
  33. for format_id in FORMATS:
  34. url = self._html_search_regex(r'data-%s-file="(.+?)"' % format_id,
  35. webpage, 'url', fatal=False)
  36. if not url:
  37. continue
  38. match = re.search(r'/(?P<height>\d+)\.mp4', url)
  39. formats.append({
  40. 'url': url,
  41. 'format_id': format_id,
  42. 'quality': quality(format_id),
  43. 'height': int(match.group('height')) if match else None,
  44. })
  45. uploader = self._html_search_regex(r'class="username".*>\s+(.+?)\n',
  46. webpage, 'uploader', fatal=False)
  47. uploader_url = ('https://www.clippituser.tv/p/' + uploader
  48. if uploader else None)
  49. timestamp = self._html_search_regex(r'datetime="(.+?)"',
  50. webpage, 'date', fatal=False)
  51. thumbnail = self._html_search_regex(r'data-image="(.+?)"',
  52. webpage, 'thumbnail', fatal=False)
  53. return {
  54. 'id': video_id,
  55. 'title': title,
  56. 'formats': formats,
  57. 'uploader': uploader,
  58. 'uploader_url': uploader_url,
  59. 'timestamp': parse_iso8601(timestamp),
  60. 'description': self._og_search_description(webpage),
  61. 'thumbnail': thumbnail,
  62. }