vidbit.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import url_basename
  6. from ..compat import compat_urlparse
  7. class VidbitIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?vidbit\.co/watch\?v=(?P<id>[\w-]+)'
  9. _TEST = {
  10. 'url': 'http://www.vidbit.co/watch?v=MrM7LeaMJq',
  11. 'md5': 'f1a579a93282a78de7e1c53220ef0f12',
  12. 'info_dict': {
  13. 'id': 'MrM7LeaMJq',
  14. 'ext': 'mp4',
  15. 'title': 'RoboCop (1987) - Dick You\'re Fired',
  16. 'thumbnail': 'http://www.vidbit.co/thumbnails/MrM7LeaMJq.jpg',
  17. }
  18. }
  19. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. webpage = self._download_webpage(url, video_id)
  22. return {
  23. 'id': video_id,
  24. 'title': self._html_search_regex(r'<h1>(.+)</h1>', webpage, 'title'),
  25. 'url': compat_urlparse.urljoin(url, self._html_search_regex(r'file:\s*(["\'])((?:(?!\1).)+)\1',
  26. webpage, 'video URL', group=2)),
  27. 'thumbnail': self._og_search_thumbnail(webpage),
  28. 'description': self._html_search_regex(r'description:(["\'])((?:(?!\1).)+)\1',
  29. webpage, 'description', None, group=2),
  30. }