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.

40 lines
1.6 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class FunnyOrDieIE(InfoExtractor):
  4. _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
  5. _TEST = {
  6. u'url': u'http://www.funnyordie.com/videos/0732f586d7/heart-shaped-box-literal-video-version',
  7. u'file': u'0732f586d7.mp4',
  8. u'md5': u'f647e9e90064b53b6e046e75d0241fbd',
  9. u'info_dict': {
  10. u"description": u"Lyrics changed to match the video. Spoken cameo by Obscurus Lupa (from ThatGuyWithTheGlasses.com). Based on a concept by Dustin McLean (DustFilms.com). Performed, edited, and written by David A. Scott.",
  11. u"title": u"Heart-Shaped Box: Literal Video Version"
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group('id')
  17. webpage = self._download_webpage(url, video_id)
  18. video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
  19. webpage, u'video URL', flags=re.DOTALL)
  20. title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
  21. r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
  22. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  23. webpage, u'description', fatal=False, flags=re.DOTALL)
  24. info = {
  25. 'id': video_id,
  26. 'url': video_url,
  27. 'ext': 'mp4',
  28. 'title': title,
  29. 'description': video_description,
  30. }
  31. return [info]