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.

62 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. class BitwaveReplayIE(InfoExtractor):
  4. IE_NAME = 'bitwave:replay'
  5. _VALID_URL = r'https?://(?:www\.)?bitwave\.tv/(?P<user>\w+)/replay/(?P<id>\w+)/?$'
  6. _TEST = {
  7. 'url': 'https://bitwave.tv/RhythmicCarnage/replay/z4P6eq5L7WDrM85UCrVr',
  8. 'only_matching': True
  9. }
  10. def _real_extract(self, url):
  11. replay_id = self._match_id(url)
  12. replay = self._download_json(
  13. 'https://api.bitwave.tv/v1/replays/' + replay_id,
  14. replay_id
  15. )
  16. return {
  17. 'id': replay_id,
  18. 'title': replay['data']['title'],
  19. 'uploader': replay['data']['name'],
  20. 'uploader_id': replay['data']['name'],
  21. 'url': replay['data']['url'],
  22. 'thumbnails': [
  23. {'url': x} for x in replay['data']['thumbnails']
  24. ],
  25. }
  26. class BitwaveStreamIE(InfoExtractor):
  27. IE_NAME = 'bitwave:stream'
  28. _VALID_URL = r'https?://(?:www\.)?bitwave\.tv/(?P<id>\w+)/?$'
  29. _TEST = {
  30. 'url': 'https://bitwave.tv/doomtube',
  31. 'only_matching': True
  32. }
  33. def _real_extract(self, url):
  34. username = self._match_id(url)
  35. channel = self._download_json(
  36. 'https://api.bitwave.tv/v1/channels/' + username,
  37. username)
  38. formats = self._extract_m3u8_formats(
  39. channel['data']['url'], username,
  40. 'mp4')
  41. self._sort_formats(formats)
  42. return {
  43. 'id': username,
  44. 'title': self._live_title(channel['data']['title']),
  45. 'uploader': username,
  46. 'uploader_id': username,
  47. 'formats': formats,
  48. 'thumbnail': channel['data']['thumbnail'],
  49. 'is_live': True,
  50. 'view_count': channel['data']['viewCount']
  51. }