streamanity.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from .common import InfoExtractor
  2. class StreamanityIE(InfoExtractor):
  3. _VALID_URL = r'https?://(?:www\.)?streamanity\.com/video/(?P<id>[A-Za-z0-9]+)'
  4. _TESTS = [{
  5. 'url': 'https://streamanity.com/video/9DFPTnuYi8f2',
  6. 'md5': '6ab171e8d4a02ad5dcbff6bea44cf5a1',
  7. 'info_dict': {
  8. 'id': '9DFPTnuYi8f2',
  9. 'ext': 'mp4',
  10. 'title': 'Bitcoin vs The Lighting Network',
  11. 'thumbnail': r're:https://res\.cloudinary\.com/.+\.png',
  12. 'description': '',
  13. 'uploader': 'Tom Bombadil (Freddy78)',
  14. }
  15. }, {
  16. 'url': 'https://streamanity.com/video/JktOUjSlfzTD',
  17. 'md5': '31f131e28abd3377c38be586a59532dc',
  18. 'info_dict': {
  19. 'id': 'JktOUjSlfzTD',
  20. 'ext': 'mp4',
  21. 'title': 'Share data when you see it',
  22. 'thumbnail': r're:https://res\.cloudinary\.com/.+\.png',
  23. 'description': 'Reposting as data should be public and stored on blockchain',
  24. 'uploader': 'digitalcurrencydaily',
  25. }
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. video_info = self._download_json(
  30. f'https://app.streamanity.com/api/video/{video_id}', video_id)['data']['video']
  31. formats = self._extract_m3u8_formats(
  32. f'https://stream.mux.com/{video_info["play_id"]}.m3u8?token={video_info["token"]}',
  33. video_id, ext='mp4', m3u8_id='hls')
  34. return {
  35. 'id': video_id,
  36. 'title': video_info['title'],
  37. 'description': video_info.get('description'),
  38. 'uploader': video_info.get('author_name'),
  39. 'is_live': False,
  40. 'thumbnail': video_info.get('thumb'),
  41. 'formats': formats,
  42. }