redtube.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import re
  2. from .common import InfoExtractor
  3. class RedTubeIE(InfoExtractor):
  4. _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
  5. _TEST = {
  6. u'url': u'http://www.redtube.com/66418',
  7. u'file': u'66418.mp4',
  8. u'md5': u'7b8c22b5e7098a3e1c09709df1126d2d',
  9. u'info_dict': {
  10. u"title": u"Sucked on a toilet",
  11. u"age_limit": 18,
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group('id')
  17. video_extension = 'mp4'
  18. webpage = self._download_webpage(url, video_id)
  19. self.report_extraction(video_id)
  20. video_url = self._html_search_regex(
  21. r'<source src="(.+?)" type="video/mp4">', webpage, u'video URL')
  22. video_title = self._html_search_regex(
  23. r'<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
  24. webpage, u'title')
  25. # No self-labeling, but they describe themselves as
  26. # "Home of Videos Porno"
  27. age_limit = 18
  28. return {
  29. 'id': video_id,
  30. 'url': video_url,
  31. 'ext': video_extension,
  32. 'title': video_title,
  33. 'age_limit': age_limit,
  34. }