[daisuki] add support for motto.daisuki.com(fixes #14681)

This commit is contained in:
Remita Amine 2017-11-28 10:55:32 +01:00
parent a3474aa59e
commit 5f699251e9
2 changed files with 41 additions and 47 deletions

View file

@ -13,33 +13,30 @@
from ..utils import ( from ..utils import (
bytes_to_intlist, bytes_to_intlist,
bytes_to_long, bytes_to_long,
clean_html, extract_attributes,
ExtractorError, ExtractorError,
intlist_to_bytes, intlist_to_bytes,
get_element_by_id,
js_to_json, js_to_json,
int_or_none, int_or_none,
long_to_bytes, long_to_bytes,
pkcs1pad, pkcs1pad,
remove_end,
) )
class DaisukiIE(InfoExtractor): class DaisukiMottoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?daisuki\.net/[^/]+/[^/]+/[^/]+/watch\.[^.]+\.(?P<id>\d+)\.html' _VALID_URL = r'https?://motto\.daisuki\.net/framewatch/embed/[^/]+/(?P<id>[0-9a-zA-Z]{3})'
_TEST = { _TEST = {
'url': 'http://www.daisuki.net/tw/en/anime/watch.TheIdolMasterCG.11213.html', 'url': 'http://motto.daisuki.net/framewatch/embed/embedDRAGONBALLSUPERUniverseSurvivalsaga/V2e/760/428',
'info_dict': { 'info_dict': {
'id': '11213', 'id': 'V2e',
'ext': 'mp4', 'ext': 'mp4',
'title': '#01 Who is in the pumpkin carriage? - THE IDOLM@STER CINDERELLA GIRLS', 'title': '#117 SHOWDOWN OF LOVE! ANDROIDS VS UNIVERSE 2!!',
'subtitles': { 'subtitles': {
'mul': [{ 'mul': [{
'ext': 'ttml', 'ext': 'ttml',
}], }],
}, },
'creator': 'BANDAI NAMCO Entertainment',
}, },
'params': { 'params': {
'skip_download': True, # AES-encrypted HLS stream 'skip_download': True, # AES-encrypted HLS stream
@ -73,7 +70,9 @@ def _real_extract(self, url):
n, e = self._RSA_KEY n, e = self._RSA_KEY
encrypted_aeskey = long_to_bytes(pow(bytes_to_long(padded_aeskey), e, n)) encrypted_aeskey = long_to_bytes(pow(bytes_to_long(padded_aeskey), e, n))
init_data = self._download_json('http://www.daisuki.net/bin/bgn/init', video_id, query={ init_data = self._download_json(
'http://motto.daisuki.net/fastAPI/bgn/init/',
video_id, query={
's': flashvars.get('s', ''), 's': flashvars.get('s', ''),
'c': flashvars.get('ss3_prm', ''), 'c': flashvars.get('ss3_prm', ''),
'e': url, 'e': url,
@ -98,14 +97,11 @@ def _real_extract(self, url):
aes_key, iv)).decode('utf-8').rstrip('\0'), aes_key, iv)).decode('utf-8').rstrip('\0'),
video_id) video_id)
title = rtn['title_str']
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
rtn['play_url'], video_id, ext='mp4', entry_protocol='m3u8_native') rtn['play_url'], video_id, ext='mp4', entry_protocol='m3u8_native')
title = remove_end(self._og_search_title(webpage), ' - DAISUKI')
creator = self._html_search_regex(
r'Creator\s*:\s*([^<]+)', webpage, 'creator', fatal=False)
subtitles = {} subtitles = {}
caption_url = rtn.get('caption_url') caption_url = rtn.get('caption_url')
if caption_url: if caption_url:
@ -120,21 +116,18 @@ def _real_extract(self, url):
'title': title, 'title': title,
'formats': formats, 'formats': formats,
'subtitles': subtitles, 'subtitles': subtitles,
'creator': creator,
} }
class DaisukiPlaylistIE(InfoExtractor): class DaisukiMottoPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)daisuki\.net/[^/]+/[^/]+/[^/]+/detail\.(?P<id>[a-zA-Z0-9]+)\.html' _VALID_URL = r'https?://motto\.daisuki\.net/(?P<id>information)/'
_TEST = { _TEST = {
'url': 'http://www.daisuki.net/tw/en/anime/detail.TheIdolMasterCG.html', 'url': 'http://motto.daisuki.net/information/',
'info_dict': { 'info_dict': {
'id': 'TheIdolMasterCG', 'title': 'DRAGON BALL SUPER',
'title': 'THE IDOLM@STER CINDERELLA GIRLS',
'description': 'md5:0f2c028a9339f7a2c7fbf839edc5c5d8',
}, },
'playlist_count': 26, 'playlist_mincount': 117,
} }
def _real_extract(self, url): def _real_extract(self, url):
@ -142,18 +135,19 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, playlist_id) webpage = self._download_webpage(url, playlist_id)
episode_pattern = r'''(?sx) entries = []
<img[^>]+delay="[^"]+/(\d+)/movie\.jpg".+? for li in re.findall(r'(<li[^>]+?data-product_id="[a-zA-Z0-9]{3}"[^>]+>)', webpage):
<p[^>]+class=".*?\bepisodeNumber\b.*?">(?:<a[^>]+>)?([^<]+)''' attr = extract_attributes(li)
entries = [{ ad_id = attr.get('data-ad_id')
product_id = attr.get('data-product_id')
if ad_id and product_id:
episode_id = attr.get('data-chapter')
entries.append({
'_type': 'url_transparent', '_type': 'url_transparent',
'url': url.replace('detail', 'watch').replace('.html', '.' + movie_id + '.html'), 'url': 'http://motto.daisuki.net/framewatch/embed/%s/%s/760/428' % (ad_id, product_id),
'episode_id': episode_id, 'episode_id': episode_id,
'episode_number': int_or_none(episode_id), 'episode_number': int_or_none(episode_id),
} for movie_id, episode_id in re.findall(episode_pattern, webpage)] 'ie_key': 'DaisukiMotto',
})
playlist_title = remove_end( return self.playlist_result(entries, playlist_title='DRAGON BALL SUPER')
self._og_search_title(webpage, fatal=False), ' - Anime - DAISUKI')
playlist_description = clean_html(get_element_by_id('synopsisTxt', webpage))
return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)

View file

@ -246,8 +246,8 @@
DailymotionCloudIE, DailymotionCloudIE,
) )
from .daisuki import ( from .daisuki import (
DaisukiIE, DaisukiMottoIE,
DaisukiPlaylistIE, DaisukiMottoPlaylistIE,
) )
from .daum import ( from .daum import (
DaumIE, DaumIE,