beeg.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. int_or_none,
  4. str_or_none,
  5. traverse_obj,
  6. try_get,
  7. unified_timestamp,
  8. )
  9. class BeegIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?beeg\.(?:com(?:/video)?)/-?(?P<id>\d+)'
  11. _TESTS = [{
  12. 'url': 'https://beeg.com/-0983946056129650',
  13. 'md5': '51d235147c4627cfce884f844293ff88',
  14. 'info_dict': {
  15. 'id': '0983946056129650',
  16. 'ext': 'mp4',
  17. 'title': 'sucked cock and fucked in a private plane',
  18. 'duration': 927,
  19. 'tags': list,
  20. 'age_limit': 18,
  21. 'upload_date': '20220131',
  22. 'timestamp': 1643656455,
  23. 'display_id': '2540839',
  24. },
  25. }, {
  26. 'url': 'https://beeg.com/-0599050563103750?t=4-861',
  27. 'md5': 'bd8b5ea75134f7f07fad63008db2060e',
  28. 'info_dict': {
  29. 'id': '0599050563103750',
  30. 'ext': 'mp4',
  31. 'title': 'Bad Relatives',
  32. 'duration': 2060,
  33. 'tags': list,
  34. 'age_limit': 18,
  35. 'description': 'md5:b4fc879a58ae6c604f8f259155b7e3b9',
  36. 'timestamp': 1643623200,
  37. 'display_id': '2569965',
  38. 'upload_date': '20220131',
  39. },
  40. }, {
  41. # api/v6 v2
  42. 'url': 'https://beeg.com/1941093077?t=911-1391',
  43. 'only_matching': True,
  44. }, {
  45. # api/v6 v2 w/o t
  46. 'url': 'https://beeg.com/1277207756',
  47. 'only_matching': True,
  48. }]
  49. def _real_extract(self, url):
  50. video_id = self._match_id(url)
  51. webpage = self._download_webpage(url, video_id)
  52. video = self._download_json(
  53. f'https://store.externulls.com/facts/file/{video_id}',
  54. video_id, f'Downloading JSON for {video_id}')
  55. fc_facts = video.get('fc_facts')
  56. first_fact = {}
  57. for fact in fc_facts:
  58. if not first_fact or try_get(fact, lambda x: x['id'] < first_fact['id']):
  59. first_fact = fact
  60. resources = traverse_obj(video, ('file', 'hls_resources')) or first_fact.get('hls_resources')
  61. formats = []
  62. for format_id, video_uri in resources.items():
  63. if not video_uri:
  64. continue
  65. height = int_or_none(self._search_regex(r'fl_cdn_(\d+)', format_id, 'height', default=None))
  66. current_formats = self._extract_m3u8_formats(f'https://video.beeg.com/{video_uri}', video_id, ext='mp4', m3u8_id=str(height))
  67. for f in current_formats:
  68. f['height'] = height
  69. formats.extend(current_formats)
  70. return {
  71. 'id': video_id,
  72. 'display_id': str_or_none(first_fact.get('id')),
  73. 'title': traverse_obj(video, ('file', 'stuff', 'sf_name')),
  74. 'description': traverse_obj(video, ('file', 'stuff', 'sf_story')),
  75. 'timestamp': unified_timestamp(first_fact.get('fc_created')),
  76. 'duration': int_or_none(traverse_obj(video, ('file', 'fl_duration'))),
  77. 'tags': traverse_obj(video, ('tags', ..., 'tg_name')),
  78. 'formats': formats,
  79. 'age_limit': self._rta_search(webpage),
  80. }