Compare commits

..

No commits in common. "091084958786d871b1dc2c36d3a56aed5415bccd" and "061a17f18b293832fe2b4b33372d437b17ecabc6" have entirely different histories.

View File

@ -1,4 +1,5 @@
import json import json
import random
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
@ -6,6 +7,7 @@ from ..utils import (
try_call, try_call,
unified_timestamp, unified_timestamp,
urlencode_postdata, urlencode_postdata,
xpath_text,
) )
@ -13,8 +15,10 @@ class EplusIbIE(InfoExtractor):
_NETRC_MACHINE = 'eplus' _NETRC_MACHINE = 'eplus'
IE_NAME = 'eplus' IE_NAME = 'eplus'
IE_DESC = 'e+ (イープラス)' IE_DESC = 'e+ (イープラス)'
_VALID_URL = [r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)', _VALID_URL = [
r'https?://live\.eplus\.jp/(?P<id>sample|\d+)'] r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)',
r'https?://live\.eplus\.jp/(?P<id>sample|\d+)',
]
_TESTS = [{ _TESTS = [{
'url': 'https://live.eplus.jp/ex/player?ib=YEFxb3Vyc2Dombnjg7blkrLlrablnJLjgrnjgq%2Fjg7zjg6vjgqLjgqTjg4njg6vlkIzlpb3kvJpgTGllbGxhIQ%3D%3D', 'url': 'https://live.eplus.jp/ex/player?ib=YEFxb3Vyc2Dombnjg7blkrLlrablnJLjgrnjgq%2Fjg7zjg6vjgqLjgqTjg4njg6vlkIzlpb3kvJpgTGllbGxhIQ%3D%3D',
'info_dict': { 'info_dict': {
@ -75,33 +79,34 @@ class EplusIbIE(InfoExtractor):
}] }]
_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0' _USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
_TEST_EVENT_URL = 'https://live.eplus.jp/2053935'
def _perform_login(self, id, password): def _perform_login(self, id, password):
fake_event_url = f'https://live.eplus.jp/{random.randrange(2000000, 10000000)}'
webpage, urlh = self._download_webpage_handle( webpage, urlh = self._download_webpage_handle(
self._TEST_EVENT_URL, None, note='Getting auth status', errnote='Unable to get auth status') fake_event_url, None, note='Getting auth status', errnote='Unable to get auth status')
if urlh.url.startswith(self._TEST_EVENT_URL): if urlh.url.startswith(fake_event_url):
# already logged in # already logged in
return return
cltft_token = self._hidden_inputs(webpage).get('Token.Default') cltft_token = self._hidden_inputs(webpage).get('Token.Default')
if not cltft_token: if not cltft_token:
raise ExtractorError('Unable to get X-CLTFT-Token', expected=False) self.report_warning('Unable to get X-CLTFT-Token')
return
self._set_cookie('live.eplus.jp', 'X-CLTFT-Token', f'Token.Default={cltft_token}') self._set_cookie('live.eplus.jp', 'X-CLTFT-Token', f'Token.Default={cltft_token}')
login_json = self._download_json( login_xml = self._download_xml(
'https://live.eplus.jp/member/api/v1/FTAuth/idpw', None, 'https://live.eplus.jp/member/api/v1/FTAuth/idpw', None,
note='Sending pre-login info', errnote='Unable to send pre-login info', headers={ note='Sending pre-login info', errnote='Unable to send pre-login info', headers={
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'Referer': urlh.url, 'Referer': urlh.url,
'X-Cltft-Token': f'Token.Default={cltft_token}', 'X-Cltft-Token': f'Token.Default={cltft_token}',
'Accept': '*/*',
}, data=json.dumps({ }, data=json.dumps({
'loginId': id, 'loginId': id,
'loginPassword': password, 'loginPassword': password,
}).encode()) }).encode('utf-8'))
if not login_json.get('isSuccess'): flag = xpath_text(login_xml, './isSuccess', default=None)
raise ExtractorError('Login failed: Invalid id or password', expected=True) if flag != 'true':
raise
self._request_webpage( self._request_webpage(
urlh.url, None, note='Logging in', errnote='Unable to log in', urlh.url, None, note='Logging in', errnote='Unable to log in',
@ -117,8 +122,7 @@ class EplusIbIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage, urlh = self._download_webpage_handle( webpage, urlh = self._download_webpage_handle(url, video_id)
url, video_id, headers={'User-Agent': self._USER_AGENT})
if urlh.url.startswith('https://live.eplus.jp/member/auth'): if urlh.url.startswith('https://live.eplus.jp/member/auth'):
self.raise_login_required() self.raise_login_required()