bandaichannel.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. from .brightcove import BrightcoveNewBaseIE
  2. from ..utils import extract_attributes
  3. class BandaiChannelIE(BrightcoveNewBaseIE):
  4. IE_NAME = 'bandaichannel'
  5. _VALID_URL = r'https?://(?:www\.)?b-ch\.com/titles/(?P<id>\d+/\d+)'
  6. _TESTS = [{
  7. 'url': 'https://www.b-ch.com/titles/514/001',
  8. 'md5': 'a0f2d787baa5729bed71108257f613a4',
  9. 'info_dict': {
  10. 'id': '6128044564001',
  11. 'ext': 'mp4',
  12. 'title': 'メタルファイターMIKU 第1話',
  13. 'timestamp': 1580354056,
  14. 'uploader_id': '5797077852001',
  15. 'upload_date': '20200130',
  16. 'duration': 1387.733,
  17. },
  18. 'params': {
  19. 'skip_download': True,
  20. },
  21. }]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. attrs = extract_attributes(self._search_regex(
  26. r'(<video-js[^>]+\bid="bcplayer"[^>]*>)', webpage, 'player'))
  27. bc = self._download_json(
  28. 'https://pbifcd.b-ch.com/v1/playbackinfo/ST/70/' + attrs['data-info'],
  29. video_id, headers={'X-API-KEY': attrs['data-auth'].strip()})['bc']
  30. return self._parse_brightcove_metadata(bc, bc['id'])