Merge 7a3b118ed1
into 7d740e7dc7
This commit is contained in:
commit
bf45ce5981
|
@ -6,6 +6,7 @@ import binascii
|
|||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..aes import aes_cbc_decrypt
|
||||
|
@ -24,6 +25,7 @@ from ..utils import (
|
|||
strip_or_none,
|
||||
urljoin,
|
||||
)
|
||||
from .openload import PhantomJSwrapper
|
||||
|
||||
|
||||
class ADNIE(InfoExtractor):
|
||||
|
@ -54,7 +56,7 @@ class ADNIE(InfoExtractor):
|
|||
def _ass_subtitles_timecode(seconds):
|
||||
return '%01d:%02d:%02d.%02d' % (seconds / 3600, (seconds % 3600) / 60, seconds % 60, (seconds % 1) * 100)
|
||||
|
||||
def _get_subtitles(self, sub_path, video_id):
|
||||
def _get_subtitles(self, sub_path, video_id, url, webpage):
|
||||
if not sub_path:
|
||||
return None
|
||||
|
||||
|
@ -70,10 +72,36 @@ class ADNIE(InfoExtractor):
|
|||
if not enc_subtitles:
|
||||
return None
|
||||
|
||||
# http://animedigitalnetwork.fr/components/com_vodvideo/videojs/adn-vjs.min.js
|
||||
# Get the second half of the encryption key
|
||||
phantom = PhantomJSwrapper(self, required_version='2.0')
|
||||
_, logs = phantom.get(url, html=webpage, video_id=video_id, jscode="""
|
||||
function getKey() {
|
||||
var key = page.evaluate(function() {
|
||||
return window.videojs &&
|
||||
window.videojs.players["adn-video-js"] &&
|
||||
window.videojs.players["adn-video-js"].onChromecastCustomData().key;
|
||||
})
|
||||
if (key) {
|
||||
console.log('Key is : ' + key);
|
||||
saveAndExit();
|
||||
} else {
|
||||
setTimeout(getKey, 1 * 1000);
|
||||
}
|
||||
}
|
||||
getKey();
|
||||
window.setTimeout(function() {
|
||||
console.error('Timed out');
|
||||
saveAndExit();
|
||||
}, 60 * 1000);
|
||||
""")
|
||||
match = re.match(re.compile(r'Key is : (.+)\n', re.MULTILINE), logs)
|
||||
if 'Timed out' in logs or match is None:
|
||||
raise ExtractorError('Could not get the key')
|
||||
key = match.group(1).strip()
|
||||
|
||||
dec_subtitles = intlist_to_bytes(aes_cbc_decrypt(
|
||||
bytes_to_intlist(compat_b64decode(enc_subtitles[24:])),
|
||||
bytes_to_intlist(binascii.unhexlify(self._K + '4b8ef13ec1872730')),
|
||||
bytes_to_intlist(binascii.unhexlify(self._K + key)),
|
||||
bytes_to_intlist(compat_b64decode(enc_subtitles[:24]))
|
||||
))
|
||||
subtitles_json = self._parse_json(
|
||||
|
@ -201,7 +229,7 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
|
|||
'description': strip_or_none(metas.get('summary') or video_info.get('resume')),
|
||||
'thumbnail': video_info.get('image'),
|
||||
'formats': formats,
|
||||
'subtitles': self.extract_subtitles(sub_path, video_id),
|
||||
'subtitles': self.extract_subtitles(sub_path, video_id, url, webpage),
|
||||
'episode': metas.get('subtitle') or video_info.get('videoTitle'),
|
||||
'series': video_info.get('playlistTitle'),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue