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.

37 lines
1.4 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. info = {
  23. 'id': video_id,
  24. 'url': video_url,
  25. 'ext': 'mp4',
  26. 'title': title,
  27. 'description': self._og_search_description(webpage),
  28. }
  29. return [info]