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