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.

57 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class BeegIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?beeg\.com/(?P<id>\d+)'
  6. _TEST = {
  7. 'url': 'http://beeg.com/5416503',
  8. 'md5': '634526ae978711f6b748fe0dd6c11f57',
  9. 'info_dict': {
  10. 'id': '5416503',
  11. 'ext': 'mp4',
  12. 'title': 'Sultry Striptease',
  13. 'description': 'md5:6db3c6177972822aaba18652ff59c773',
  14. 'categories': list, # NSFW
  15. 'thumbnail': 're:https?://.*\.jpg$',
  16. 'age_limit': 18,
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('id')
  22. webpage = self._download_webpage(url, video_id)
  23. video_url = self._html_search_regex(
  24. r"'480p'\s*:\s*'([^']+)'", webpage, 'video URL')
  25. title = self._html_search_regex(
  26. r'<title>([^<]+)\s*-\s*beeg\.?</title>', webpage, 'title')
  27. description = self._html_search_regex(
  28. r'<meta name="description" content="([^"]*)"',
  29. webpage, 'description', fatal=False)
  30. thumbnail = self._html_search_regex(
  31. r'\'previewer.url\'\s*:\s*"([^"]*)"',
  32. webpage, 'thumbnail', fatal=False)
  33. categories_str = self._html_search_regex(
  34. r'<meta name="keywords" content="([^"]+)"', webpage, 'categories', fatal=False)
  35. categories = (
  36. None if categories_str is None
  37. else categories_str.split(','))
  38. return {
  39. 'id': video_id,
  40. 'url': video_url,
  41. 'title': title,
  42. 'description': description,
  43. 'thumbnail': thumbnail,
  44. 'categories': categories,
  45. 'age_limit': 18,
  46. }