beeg.py 1.5 KB

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