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.

90 lines
2.8 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..compat import compat_str
  4. from ..utils import (
  5. int_or_none,
  6. unified_timestamp,
  7. )
  8. class BeegIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?beeg\.(?:com|porn(?:/video)?)/(?P<id>\d+)'
  10. _TESTS = [{
  11. 'url': 'http://beeg.com/5416503',
  12. 'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820',
  13. 'info_dict': {
  14. 'id': '5416503',
  15. 'ext': 'mp4',
  16. 'title': 'Sultry Striptease',
  17. 'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',
  18. 'timestamp': 1391813355,
  19. 'upload_date': '20140207',
  20. 'duration': 383,
  21. 'tags': list,
  22. 'age_limit': 18,
  23. }
  24. }, {
  25. 'url': 'https://beeg.porn/video/5416503',
  26. 'only_matching': True,
  27. }, {
  28. 'url': 'https://beeg.porn/5416503',
  29. 'only_matching': True,
  30. }]
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. webpage = self._download_webpage(url, video_id)
  34. beeg_version = self._search_regex(
  35. r'beeg_version\s*=\s*([\da-zA-Z_-]+)', webpage, 'beeg version',
  36. default='1546225636701')
  37. for api_path in ('', 'api.'):
  38. video = self._download_json(
  39. 'https://%sbeeg.com/api/v6/%s/video/%s'
  40. % (api_path, beeg_version, video_id), video_id,
  41. fatal=api_path == 'api.')
  42. if video:
  43. break
  44. formats = []
  45. for format_id, video_url in video.items():
  46. if not video_url:
  47. continue
  48. height = self._search_regex(
  49. r'^(\d+)[pP]$', format_id, 'height', default=None)
  50. if not height:
  51. continue
  52. formats.append({
  53. 'url': self._proto_relative_url(
  54. video_url.replace('{DATA_MARKERS}', 'data=pc_XX__%s_0' % beeg_version), 'https:'),
  55. 'format_id': format_id,
  56. 'height': int(height),
  57. })
  58. self._sort_formats(formats)
  59. title = video['title']
  60. video_id = compat_str(video.get('id') or video_id)
  61. display_id = video.get('code')
  62. description = video.get('desc')
  63. series = video.get('ps_name')
  64. timestamp = unified_timestamp(video.get('date'))
  65. duration = int_or_none(video.get('duration'))
  66. tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
  67. return {
  68. 'id': video_id,
  69. 'display_id': display_id,
  70. 'title': title,
  71. 'description': description,
  72. 'series': series,
  73. 'timestamp': timestamp,
  74. 'duration': duration,
  75. 'tags': tags,
  76. 'formats': formats,
  77. 'age_limit': self._rta_search(webpage),
  78. }