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.

53 lines
1.7 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. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. video_url = self._html_search_regex(
  23. r"'480p'\s*:\s*'([^']+)'", webpage, 'video URL')
  24. title = self._html_search_regex(
  25. r'<title>([^<]+)\s*-\s*beeg\.?</title>', webpage, 'title')
  26. description = self._html_search_regex(
  27. r'<meta name="description" content="([^"]*)"',
  28. webpage, 'description', fatal=False)
  29. thumbnail = self._html_search_regex(
  30. r'\'previewer.url\'\s*:\s*"([^"]*)"',
  31. webpage, 'thumbnail', fatal=False)
  32. categories_str = self._html_search_regex(
  33. r'<meta name="keywords" content="([^"]+)"', webpage, 'categories', fatal=False)
  34. categories = categories_str.split(',')
  35. return {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'title': title,
  39. 'description': description,
  40. 'thumbnail': thumbnail,
  41. 'categories': categories,
  42. }