You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urlparse,
  6. determine_ext,
  7. int_or_none,
  8. )
  9. class QuickVidIE(InfoExtractor):
  10. _VALID_URL = r'https?://(www\.)?quickvid\.org/watch\.php\?v=(?P<id>[a-zA-Z_0-9-]+)'
  11. _TEST = {
  12. 'url': 'http://quickvid.org/watch.php?v=sUQT3RCG8dx',
  13. 'md5': 'c0c72dd473f260c06c808a05d19acdc5',
  14. 'info_dict': {
  15. 'id': 'sUQT3RCG8dx',
  16. 'ext': 'mp4',
  17. 'title': 'Nick Offerman\'s Summer Reading Recap',
  18. 'thumbnail': 're:^https?://.*\.(?:png|jpg|gif)$',
  19. 'view_count': int,
  20. },
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. title = self._html_search_regex(r'<h2>(.*?)</h2>', webpage, 'title')
  26. view_count = int_or_none(self._html_search_regex(
  27. r'(?s)<div id="views">(.*?)</div>',
  28. webpage, 'view count', fatal=False))
  29. video_code = self._search_regex(
  30. r'(?s)<video id="video"[^>]*>(.*?)</video>', webpage, 'video code')
  31. formats = [
  32. {
  33. 'url': compat_urlparse.urljoin(url, src),
  34. 'format_id': determine_ext(src, None),
  35. } for src in re.findall('<source\s+src="([^"]+)"', video_code)
  36. ]
  37. self._sort_formats(formats)
  38. return {
  39. 'id': video_id,
  40. 'title': title,
  41. 'formats': formats,
  42. 'thumbnail': self._og_search_thumbnail(webpage),
  43. 'view_count': view_count,
  44. }