parler.py 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import functools
  2. from .common import InfoExtractor
  3. from .youtube import YoutubeIE
  4. from ..utils import (
  5. clean_html,
  6. int_or_none,
  7. strip_or_none,
  8. traverse_obj,
  9. unified_timestamp,
  10. urljoin,
  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': 1659785481,
  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/f23b85c1-6558-470f-b9ff-02c145f28da5',
  37. 'md5': 'eaba1ff4a10fe281f5ce74e930ab2cb4',
  38. 'info_dict': {
  39. 'id': 'r5vkSaz8PxQ',
  40. 'ext': 'mp4',
  41. 'live_status': 'not_live',
  42. 'comment_count': int,
  43. 'duration': 1267,
  44. 'like_count': int,
  45. 'channel_follower_count': int,
  46. 'channel_id': 'UCox6YeMSY1PQInbCtTaZj_w',
  47. 'upload_date': '20220716',
  48. 'thumbnail': 'https://i.ytimg.com/vi/r5vkSaz8PxQ/maxresdefault.jpg',
  49. 'tags': 'count:17',
  50. 'availability': 'public',
  51. 'categories': ['Entertainment'],
  52. 'playable_in_embed': True,
  53. 'channel': 'Who Knows What! With Mahesh & Friends',
  54. 'title': 'Tom MacDonald Names Reaction',
  55. 'uploader': 'Who Knows What! With Mahesh & Friends',
  56. 'uploader_id': '@maheshchookolingo',
  57. 'age_limit': 0,
  58. 'description': 'md5:33c21f0d35ae6dc2edf3007d6696baea',
  59. 'channel_url': 'https://www.youtube.com/channel/UCox6YeMSY1PQInbCtTaZj_w',
  60. 'view_count': int,
  61. 'uploader_url': 'http://www.youtube.com/@maheshchookolingo',
  62. },
  63. },
  64. ]
  65. def _real_extract(self, url):
  66. video_id = self._match_id(url)
  67. data = self._download_json(f'https://api.parler.com/v0/public/parleys/{video_id}',
  68. video_id)['data']
  69. if data.get('link'):
  70. return self.url_result(data['link'], YoutubeIE)
  71. return {
  72. 'id': video_id,
  73. 'title': strip_or_none(data.get('title')) or '',
  74. **traverse_obj(data, {
  75. 'url': ('video', 'videoSrc'),
  76. 'thumbnail': ('video', 'thumbnailUrl'),
  77. 'description': ('body', {clean_html}),
  78. 'timestamp': ('date_created', {unified_timestamp}),
  79. 'uploader': ('user', 'name', {strip_or_none}),
  80. 'uploader_id': ('user', 'username', {str}),
  81. 'uploader_url': ('user', 'username', {functools.partial(urljoin, 'https://parler.com/')}),
  82. 'view_count': ('views', {int_or_none}),
  83. 'comment_count': ('total_comments', {int_or_none}),
  84. 'repost_count': ('echos', {int_or_none}),
  85. }),
  86. }