freevideo.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. )
  7. class FreeVideoIE(InfoExtractor):
  8. _VALID_URL = r'^http://www.freevideo.cz/vase-videa/(?P<videoid>[^.]+)\.html$'
  9. _TEST = {
  10. 'url': 'http://www.freevideo.cz/vase-videa/vysukany-zadecek-22033.html',
  11. 'file': 'vysukany-zadecek-22033.mp4',
  12. 'info_dict': {
  13. "title": "vysukany-zadecek-22033",
  14. "age_limit": 18,
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. if mobj is None:
  20. raise ExtractorError('Invalid search query "%s"' % query)
  21. video_id = mobj.group('videoid')
  22. # Get webpage content
  23. webpage = self._download_webpage(url, video_id)
  24. age_limit = self._rta_search(webpage)
  25. if age_limit == 0:
  26. # interpret 0 as mis-detection since this site is adult-content only.
  27. # However, if we get non-0, assume the rtalabel started giving proper
  28. # results
  29. age_limit = 18
  30. url = re.search(r'\s+url: "(http://[a-z0-9-]+.cdn.freevideo.cz/stream/.*/video.mp4)"', webpage)
  31. if url is None:
  32. raise ExtractorError('ERROR: unable to extract video url')
  33. return {
  34. 'id': video_id,
  35. 'url': url.groups()[0],
  36. 'title': video_id,
  37. 'age_limit': age_limit,
  38. }