2020-03-21 23:35:56 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2020-03-22 01:39:44 +00:00
|
|
|
from ..utils import (
|
|
|
|
clean_html,
|
|
|
|
get_element_by_id,
|
|
|
|
)
|
2020-03-21 23:35:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DigitalConcertHallIE(InfoExtractor):
|
|
|
|
IE_DESC = 'DigitalConcertHall extractor'
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?digitalconcerthall\.com/(?P<language>[a-z]+)/concert/(?P<id>[0-9]+)'
|
2020-03-22 01:46:55 +00:00
|
|
|
_TEST = {
|
2020-03-21 23:35:56 +00:00
|
|
|
'url': 'https://www.digitalconcerthall.com/en/concert/51841',
|
|
|
|
'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '51841',
|
|
|
|
'language': 'en',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Video title goes here',
|
|
|
|
'thumbnail': r're:^https?://.*/images/core/Phil.*\.jpg$',
|
|
|
|
}
|
2020-03-22 01:46:55 +00:00
|
|
|
}
|
2020-03-21 23:35:56 +00:00
|
|
|
|
2020-03-22 01:39:44 +00:00
|
|
|
def debug_out(self, args):
|
|
|
|
if not self._downloader.params.get('verbose', False):
|
|
|
|
return
|
|
|
|
|
|
|
|
self.to_screen('[debug] %s' % args)
|
|
|
|
|
2020-03-21 23:35:56 +00:00
|
|
|
def _real_extract(self, url):
|
|
|
|
language, video_id = re.match(self._VALID_URL, url).groups()
|
|
|
|
if not language:
|
|
|
|
language = 'en'
|
2020-03-22 01:39:44 +00:00
|
|
|
self.debug_out("url: " + url + " video_id: " + video_id + " language: " + language)
|
2020-03-21 23:35:56 +00:00
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
|
2020-03-22 01:39:44 +00:00
|
|
|
self.to_screen("title: " + title)
|
2020-03-21 23:35:56 +00:00
|
|
|
|
2020-03-22 01:46:55 +00:00
|
|
|
# this returns JSON containing the urls of the playlist
|
2020-03-21 23:35:56 +00:00
|
|
|
playlist_dict = self._download_json(
|
|
|
|
'https://www.digitalconcerthall.com/json_services/get_stream_urls?id=' + video_id + "&language=" + language, video_id)['urls']
|
|
|
|
|
|
|
|
entries = []
|
|
|
|
for key in playlist_dict:
|
2020-03-22 01:39:44 +00:00
|
|
|
self.debug_out("key: " + key)
|
2020-03-22 00:31:19 +00:00
|
|
|
m3u8_url = playlist_dict[key][0]['url']
|
2020-03-22 01:39:44 +00:00
|
|
|
self.debug_out("key url: " + m3u8_url)
|
2020-03-22 00:31:19 +00:00
|
|
|
formats = self._extract_m3u8_formats(m3u8_url, key, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)
|
2020-03-22 01:39:44 +00:00
|
|
|
self.debug_out(formats)
|
2020-03-22 01:46:55 +00:00
|
|
|
# the div with id=key contains the video title
|
2020-03-22 01:39:44 +00:00
|
|
|
vid_info_div = clean_html(get_element_by_id(key, webpage))
|
|
|
|
self.debug_out("vid_info_div:\n" + vid_info_div)
|
2020-03-22 01:55:21 +00:00
|
|
|
title = re.sub(r'\s+', ' ', vid_info_div)
|
|
|
|
self.to_screen("title: " + title)
|
2020-03-21 23:52:33 +00:00
|
|
|
entries.append({
|
2020-03-22 00:31:19 +00:00
|
|
|
'id': key,
|
|
|
|
'title': title,
|
|
|
|
'url': m3u8_url,
|
|
|
|
'formats': formats,
|
2020-03-21 23:52:33 +00:00
|
|
|
})
|
2020-03-21 23:35:56 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'playlist',
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'entries': entries,
|
|
|
|
}
|