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.

54 lines
1.7 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. 'skip': 'Not accessible from Travis CI server',
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. title = self._html_search_regex(r'<h2>(.*?)</h2>', webpage, 'title')
  29. view_count = int_or_none(self._html_search_regex(
  30. r'(?s)<div id="views">(.*?)</div>',
  31. webpage, 'view count', fatal=False))
  32. video_code = self._search_regex(
  33. r'(?s)<video id="video"[^>]*>(.*?)</video>', webpage, 'video code')
  34. formats = [
  35. {
  36. 'url': compat_urlparse.urljoin(url, src),
  37. 'format_id': determine_ext(src, None),
  38. } for src in re.findall('<source\s+src="([^"]+)"', video_code)
  39. ]
  40. self._sort_formats(formats)
  41. return {
  42. 'id': video_id,
  43. 'title': title,
  44. 'formats': formats,
  45. 'thumbnail': self._og_search_thumbnail(webpage),
  46. 'view_count': view_count,
  47. }