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.

56 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import int_or_none
  5. class UbuIE(InfoExtractor):
  6. _VALID_URL = r'http://(?:www\.)?ubu\.com/film/(?P<id>[\da-z_-]+)\.html'
  7. _TEST = {
  8. 'url': 'http://ubu.com/film/her_noise.html',
  9. 'md5': '8edd46ee8aa6b265fb5ed6cf05c36bc9',
  10. 'info_dict': {
  11. 'id': 'her_noise',
  12. 'ext': 'mp4',
  13. 'title': 'Her Noise - The Making Of (2007)',
  14. 'duration': 3600,
  15. },
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. title = self._html_search_regex(
  22. r'<title>.+?Film &amp; Video: ([^<]+)</title>', webpage, 'title')
  23. duration = int_or_none(self._html_search_regex(
  24. r'Duration: (\d+) minutes', webpage, 'duration', fatal=False, default=None))
  25. if duration:
  26. duration *= 60
  27. formats = []
  28. FORMAT_REGEXES = [
  29. ['sq', r"'flashvars'\s*,\s*'file=([^']+)'"],
  30. ['hq', r'href="(http://ubumexico\.centro\.org\.mx/video/[^"]+)"']
  31. ]
  32. for format_id, format_regex in FORMAT_REGEXES:
  33. m = re.search(format_regex, webpage)
  34. if m:
  35. formats.append({
  36. 'url': m.group(1),
  37. 'format_id': format_id,
  38. })
  39. return {
  40. 'id': video_id,
  41. 'title': title,
  42. 'duration': duration,
  43. 'formats': formats,
  44. }