logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

bandaichannel.py (1335B)


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