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.

65 lines
2.0 KiB

10 years ago
10 years ago
  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': '1bff67111adb785c51d1b42959ec10e5',
  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. quality_arr = self._search_regex(
  24. r'(?s)var\s+qualityArr\s*=\s*{\s*(.+?)\s*}', webpage, 'quality formats')
  25. formats = [{
  26. 'url': fmt[1],
  27. 'format_id': fmt[0],
  28. 'height': int(fmt[0][:-1]),
  29. } for fmt in re.findall(r"'([^']+)'\s*:\s*'([^']+)'", quality_arr)]
  30. self._sort_formats(formats)
  31. title = self._html_search_regex(
  32. r'<title>([^<]+)\s*-\s*beeg\.?</title>', webpage, 'title')
  33. description = self._html_search_regex(
  34. r'<meta name="description" content="([^"]*)"',
  35. webpage, 'description', fatal=False)
  36. thumbnail = self._html_search_regex(
  37. r'\'previewer.url\'\s*:\s*"([^"]*)"',
  38. webpage, 'thumbnail', fatal=False)
  39. categories_str = self._html_search_regex(
  40. r'<meta name="keywords" content="([^"]+)"', webpage, 'categories', fatal=False)
  41. categories = (
  42. None if categories_str is None
  43. else categories_str.split(','))
  44. return {
  45. 'id': video_id,
  46. 'title': title,
  47. 'description': description,
  48. 'thumbnail': thumbnail,
  49. 'categories': categories,
  50. 'formats': formats,
  51. 'age_limit': 18,
  52. }