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.

53 lines
1.6 KiB

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