[RCTIPlus] Remove PhantomJS dependency (#595)

Authored by: MinePlayersPE
This commit is contained in:
MinePlayersPE 2021-07-31 04:52:52 +07:00 committed by GitHub
parent 3619f78d2c
commit d9e6e9481e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 11 deletions

View File

@ -2,9 +2,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import itertools import itertools
import json
import re import re
import time
from .openload import PhantomJSwrapper
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
@ -88,6 +88,16 @@ class RCTIPlusIE(RCTIPlusBaseIE):
'format': 'bestvideo', 'format': 'bestvideo',
}, },
}] }]
_CONVIVA_JSON_TEMPLATE = {
't': 'CwsSessionHb',
'cid': 'ff84ae928c3b33064b76dec08f12500465e59a6f',
'clid': '0',
'sid': 0,
'seq': 0,
'caps': 0,
'sf': 7,
'sdk': True,
}
def _search_auth_key(self, webpage): def _search_auth_key(self, webpage):
try: try:
@ -105,15 +115,18 @@ class RCTIPlusIE(RCTIPlusBaseIE):
'https://api.rctiplus.com/api/v1/%s/%s/url?appierid=.1' % (video_type, video_id), display_id, 'Downloading video URL JSON')[0] 'https://api.rctiplus.com/api/v1/%s/%s/url?appierid=.1' % (video_type, video_id), display_id, 'Downloading video URL JSON')[0]
video_url = video_json['url'] video_url = video_json['url']
if 'akamaized' in video_url: if 'akamaized' in video_url:
# Akamai's CDN requires a session to at least be made via Conviva's API # For some videos hosted on Akamai's CDN (possibly AES-encrypted ones?), a session needs to at least be made via Conviva's API
# TODO: Reverse-engineer Conviva's heartbeat code to avoid phantomJS conviva_json_data = {
phantom = None **self._CONVIVA_JSON_TEMPLATE,
try: 'url': video_url,
phantom = PhantomJSwrapper(self) 'sst': int(time.time())
phantom.get(url, webpage, display_id, note2='Initiating video session') }
except ExtractorError: conviva_json_res = self._download_json(
self.report_warning('PhantomJS is highly recommended for this video, as it might load incredibly slowly otherwise.' 'https://ff84ae928c3b33064b76dec08f12500465e59a6f.cws.conviva.com/0/wsg', display_id,
'You can also try opening the page in this device\'s browser first') 'Creating Conviva session', 'Failed to create Conviva session',
fatal=False, data=json.dumps(conviva_json_data).encode('utf-8'))
if conviva_json_res and conviva_json_res.get('err') != 'ok':
self.report_warning('Conviva said: %s' % str(conviva_json_res.get('err')))
video_meta, meta_paths = self._call_api( video_meta, meta_paths = self._call_api(
'https://api.rctiplus.com/api/v1/%s/%s' % (video_type, video_id), display_id, 'Downloading video metadata') 'https://api.rctiplus.com/api/v1/%s/%s' % (video_type, video_id), display_id, 'Downloading video metadata')