axs.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. float_or_none,
  4. js_to_json,
  5. parse_iso8601,
  6. traverse_obj,
  7. url_or_none,
  8. )
  9. class AxsIE(InfoExtractor):
  10. IE_NAME = 'axs.tv'
  11. _VALID_URL = r'https?://(?:www\.)?axs\.tv/(?:channel/(?:[^/?#]+/)+)?video/(?P<id>[^/?#]+)'
  12. _TESTS = [{
  13. 'url': 'https://www.axs.tv/video/5f4dc776b70e4f1c194f22ef/',
  14. 'md5': '8d97736ae8e50c64df528e5e676778cf',
  15. 'info_dict': {
  16. 'id': '5f4dc776b70e4f1c194f22ef',
  17. 'title': 'Small Town',
  18. 'ext': 'mp4',
  19. 'description': 'md5:e314d28bfaa227a4d7ec965fae19997f',
  20. 'upload_date': '20230602',
  21. 'timestamp': 1685729564,
  22. 'duration': 1284.216,
  23. 'series': 'Rock & Roll Road Trip with Sammy Hagar',
  24. 'season': 'Season 2',
  25. 'season_number': 2,
  26. 'episode': '3',
  27. 'thumbnail': 'https://images.dotstudiopro.com/5f4e9d330a0c3b295a7e8394',
  28. },
  29. }, {
  30. 'url': 'https://www.axs.tv/channel/rock-star-interview/video/daryl-hall',
  31. 'md5': '300ae795cd8f9984652c0949734ffbdc',
  32. 'info_dict': {
  33. 'id': '5f488148b70e4f392572977c',
  34. 'display_id': 'daryl-hall',
  35. 'title': 'Daryl Hall',
  36. 'ext': 'mp4',
  37. 'description': 'md5:e54ecaa0f4b5683fc9259e9e4b196628',
  38. 'upload_date': '20230214',
  39. 'timestamp': 1676403615,
  40. 'duration': 2570.668,
  41. 'series': 'The Big Interview with Dan Rather',
  42. 'season': 'Season 3',
  43. 'season_number': 3,
  44. 'episode': '5',
  45. 'thumbnail': 'https://images.dotstudiopro.com/5f4d1901f340b50d937cec32',
  46. },
  47. }]
  48. def _real_extract(self, url):
  49. display_id = self._match_id(url)
  50. webpage = self._download_webpage(url, display_id)
  51. webpage_json_data = self._search_json(
  52. r'mountObj\s*=', webpage, 'video ID data', display_id,
  53. transform_source=js_to_json)
  54. video_id = webpage_json_data['video_id']
  55. company_id = webpage_json_data['company_id']
  56. meta = self._download_json(
  57. f'https://api.myspotlight.tv/dotplayer/video/{company_id}/{video_id}',
  58. video_id, query={'device_type': 'desktop_web'})['video']
  59. formats = self._extract_m3u8_formats(
  60. meta['video_m3u8'], video_id, 'mp4', m3u8_id='hls')
  61. subtitles = {}
  62. for cc in traverse_obj(meta, ('closeCaption', lambda _, v: url_or_none(v['srtPath']))):
  63. subtitles.setdefault(cc.get('srtShortLang') or 'en', []).append(
  64. {'ext': cc.get('srtExt'), 'url': cc['srtPath']})
  65. return {
  66. 'id': video_id,
  67. 'display_id': display_id,
  68. 'formats': formats,
  69. **traverse_obj(meta, {
  70. 'title': ('title', {str}),
  71. 'description': ('description', {str}),
  72. 'series': ('seriestitle', {str}),
  73. 'season_number': ('season', {int}),
  74. 'episode': ('episode', {str}),
  75. 'duration': ('duration', {float_or_none}),
  76. 'timestamp': ('updated_at', {parse_iso8601}),
  77. 'thumbnail': ('thumb', {url_or_none}),
  78. }),
  79. 'subtitles': subtitles,
  80. }