This commit is contained in:
bato3 2020-09-24 09:22:39 +02:00 committed by GitHub
commit 1176a33952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 53 additions and 1 deletions

View File

@ -22,6 +22,7 @@ from ..utils import (
long_to_bytes,
pkcs1pad,
strip_or_none,
urlencode_postdata,
urljoin,
)
@ -39,7 +40,9 @@ class ADNIE(InfoExtractor):
'description': 'md5:2f7b5aa76edbc1a7a92cedcda8a528d5',
}
}
_BASE_URL = 'http://animedigitalnetwork.fr'
_BASE_URL = 'https://animedigitalnetwork.fr'
_LOGIN_URL = 'https://animedigitalnetwork.fr/connexion'
_NETRC_MACHINE = 'ADN'
_RSA_KEY = (0xc35ae1e4356b65a73b551493da94b8cb443491c0aa092a357a5aee57ffc14dda85326f42d716e539a34542a0d3f363adf16c5ec222d713d5997194030ee2e4f0d1fb328c01a81cf6868c090d50de8e169c6b13d1675b9eeed1cbc51e1fffca9b38af07f37abd790924cd3bee59d0257cfda4fe5f3f0534877e21ce5821447d1b, 65537)
_POS_ALIGN_MAP = {
'start': 1,
@ -54,6 +57,46 @@ class ADNIE(InfoExtractor):
def _ass_subtitles_timecode(seconds):
return '%01d:%02d:%02d.%02d' % (seconds / 3600, (seconds % 3600) / 60, seconds % 60, (seconds % 1) * 100)
def _login(self):
username, password = self._get_login_info()
if username is None:
return
login_page = self._download_webpage(
self._LOGIN_URL, None, 'Downloading login page')
def is_logged(webpage):
return 'task=user.logout' in webpage or 'view=logout' in webpage
# Already logged in
if is_logged(login_page):
return
form_data = self._form_hidden_inputs('login-form', login_page)
form_data.update({
'username': username,
'password': password,
})
response = self._download_webpage(
self._LOGIN_URL + '?task=user.login',
None, 'Logging in', 'Wrong login info',
data=urlencode_postdata(form_data))
# Successful login
if is_logged(response):
return
error = self._html_search_regex(
r'(?s)<dd[^>]+class=["\']error message["\'][^>]*>(.+?)</ul>',
response, 'error message', default=None)
if error:
raise ExtractorError('Unable to login: %s' % error, expected=True)
raise ExtractorError('Unable to log in')
def _real_initialize(self):
self._login()
def _get_subtitles(self, sub_path, video_id):
if not sub_path:
return None
@ -162,6 +205,15 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
'Downloading links JSON metadata', headers={
'Authorization': 'Bearer ' + authorization,
})
error = links_data.get('error')
if error:
if links_data.get('code') == 1:
self.raise_login_required(error)
if links_data.get('code') == 0:
if 'Pour des raisons l' in error:
self.raise_geo_restricted(error)
else:
raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
links = links_data.get('links') or {}
metas = metas or links_data.get('meta') or {}
sub_path = sub_path or links_data.get('subtitles') or \