parler.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. from .common import InfoExtractor
  2. from .youtube import YoutubeIE
  3. from ..utils import (
  4. clean_html,
  5. format_field,
  6. int_or_none,
  7. strip_or_none,
  8. traverse_obj,
  9. unified_timestamp,
  10. urlencode_postdata,
  11. )
  12. class ParlerIE(InfoExtractor):
  13. IE_DESC = 'Posts on parler.com'
  14. _VALID_URL = r'https://parler\.com/feed/(?P<id>[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})'
  15. _TESTS = [
  16. {
  17. 'url': 'https://parler.com/feed/df79fdba-07cc-48fe-b085-3293897520d7',
  18. 'md5': '16e0f447bf186bb3cf64de5bbbf4d22d',
  19. 'info_dict': {
  20. 'id': 'df79fdba-07cc-48fe-b085-3293897520d7',
  21. 'ext': 'mp4',
  22. 'thumbnail': 'https://bl-images.parler.com/videos/6ce7cdf3-a27a-4d72-bf9c-d3e17ce39a66/thumbnail.jpeg',
  23. 'title': 'Parler video #df79fdba-07cc-48fe-b085-3293897520d7',
  24. 'description': 'md5:6f220bde2df4a97cbb89ac11f1fd8197',
  25. 'timestamp': 1659744000,
  26. 'upload_date': '20220806',
  27. 'uploader': 'Tulsi Gabbard',
  28. 'uploader_id': 'TulsiGabbard',
  29. 'uploader_url': 'https://parler.com/TulsiGabbard',
  30. 'view_count': int,
  31. 'comment_count': int,
  32. 'repost_count': int,
  33. },
  34. },
  35. {
  36. 'url': 'https://parler.com/feed/a7406eb4-91e5-4793-b5e3-ade57a24e287',
  37. 'md5': '11687e2f5bb353682cee338d181422ed',
  38. 'info_dict': {
  39. 'id': 'a7406eb4-91e5-4793-b5e3-ade57a24e287',
  40. 'ext': 'mp4',
  41. 'thumbnail': 'https://bl-images.parler.com/videos/317827a8-1e48-4cbc-981f-7dd17d4c1183/thumbnail.jpeg',
  42. 'title': 'Parler video #a7406eb4-91e5-4793-b5e3-ade57a24e287',
  43. 'description': 'This man should run for office',
  44. 'timestamp': 1659657600,
  45. 'upload_date': '20220805',
  46. 'uploader': 'Benny Johnson',
  47. 'uploader_id': 'BennyJohnson',
  48. 'uploader_url': 'https://parler.com/BennyJohnson',
  49. 'view_count': int,
  50. 'comment_count': int,
  51. 'repost_count': int,
  52. },
  53. },
  54. {
  55. 'url': 'https://parler.com/feed/f23b85c1-6558-470f-b9ff-02c145f28da5',
  56. 'md5': 'eaba1ff4a10fe281f5ce74e930ab2cb4',
  57. 'info_dict': {
  58. 'id': 'r5vkSaz8PxQ',
  59. 'ext': 'mp4',
  60. 'thumbnail': 'https://i.ytimg.com/vi_webp/r5vkSaz8PxQ/maxresdefault.webp',
  61. 'title': 'Tom MacDonald Names Reaction',
  62. 'description': 'md5:33c21f0d35ae6dc2edf3007d6696baea',
  63. 'upload_date': '20220716',
  64. 'duration': 1267,
  65. 'uploader': 'Mahesh Chookolingo',
  66. 'uploader_id': 'maheshchookolingo',
  67. 'uploader_url': 'http://www.youtube.com/user/maheshchookolingo',
  68. 'channel': 'Mahesh Chookolingo',
  69. 'channel_id': 'UCox6YeMSY1PQInbCtTaZj_w',
  70. 'channel_url': 'https://www.youtube.com/channel/UCox6YeMSY1PQInbCtTaZj_w',
  71. 'categories': ['Entertainment'],
  72. 'tags': list,
  73. 'availability': 'public',
  74. 'live_status': 'not_live',
  75. 'view_count': int,
  76. 'comment_count': int,
  77. 'like_count': int,
  78. 'channel_follower_count': int,
  79. 'age_limit': 0,
  80. 'playable_in_embed': True,
  81. },
  82. },
  83. ]
  84. def _real_extract(self, url):
  85. video_id = self._match_id(url)
  86. data = self._download_json(
  87. 'https://parler.com/open-api/ParleyDetailEndpoint.php', video_id,
  88. data=urlencode_postdata({'uuid': video_id}))['data'][0]
  89. primary = data['primary']
  90. embed = self._parse_json(primary.get('V2LINKLONG') or '', video_id, fatal=False)
  91. if embed:
  92. return self.url_result(embed[0], YoutubeIE)
  93. return {
  94. 'id': video_id,
  95. 'url': traverse_obj(primary, ('video_data', 'videoSrc')),
  96. 'thumbnail': traverse_obj(primary, ('video_data', 'thumbnailUrl')),
  97. 'title': '',
  98. 'description': strip_or_none(clean_html(primary.get('full_body'))) or None,
  99. 'timestamp': unified_timestamp(primary.get('date_created')),
  100. 'uploader': strip_or_none(primary.get('name')),
  101. 'uploader_id': strip_or_none(primary.get('username')),
  102. 'uploader_url': format_field(strip_or_none(primary.get('username')), None, 'https://parler.com/%s'),
  103. 'view_count': int_or_none(primary.get('view_count')),
  104. 'comment_count': int_or_none(traverse_obj(data, ('engagement', 'commentCount'))),
  105. 'repost_count': int_or_none(traverse_obj(data, ('engagement', 'echoCount'))),
  106. }