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.

31 lines
1.1 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. def _real_extract(self, url):
  6. mobj = re.match(self._VALID_URL, url)
  7. video_id = mobj.group('id')
  8. webpage = self._download_webpage(url, video_id)
  9. video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
  10. webpage, u'video URL', flags=re.DOTALL)
  11. title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
  12. r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
  13. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  14. webpage, u'description', fatal=False, flags=re.DOTALL)
  15. info = {
  16. 'id': video_id,
  17. 'url': video_url,
  18. 'ext': 'mp4',
  19. 'title': title,
  20. 'description': video_description,
  21. }
  22. return [info]