X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/e8cd8c4bd832446f1971215b9fedc4531555dc1a..e009904fe0a9f1250496bb42c12d66e8cca4c447:/youtube_dl/extractor/lynda.py diff --git a/youtube_dl/extractor/lynda.py b/youtube_dl/extractor/lynda.py index 6deed27..3084c6d 100644 --- a/youtube_dl/extractor/lynda.py +++ b/youtube_dl/extractor/lynda.py @@ -1,75 +1,220 @@ from __future__ import unicode_literals import re -import json -from .subtitles import SubtitlesInfoExtractor from .common import InfoExtractor +from ..compat import ( + compat_str, + compat_urlparse, +) from ..utils import ( - compat_urllib_parse, - compat_urllib_request, - ExtractorError + ExtractorError, + int_or_none, + urlencode_postdata, ) -class LyndaIE(SubtitlesInfoExtractor): +class LyndaBaseIE(InfoExtractor): + _SIGNIN_URL = 'https://www.lynda.com/signin/lynda' + _PASSWORD_URL = 'https://www.lynda.com/signin/password' + _USER_URL = 'https://www.lynda.com/signin/user' + _ACCOUNT_CREDENTIALS_HINT = 'Use --username and --password options to provide lynda.com account credentials.' + _NETRC_MACHINE = 'lynda' + + def _real_initialize(self): + self._login() + + @staticmethod + def _check_error(json_string, key_or_keys): + keys = [key_or_keys] if isinstance(key_or_keys, compat_str) else key_or_keys + for key in keys: + error = json_string.get(key) + if error: + raise ExtractorError('Unable to login: %s' % error, expected=True) + + def _login_step(self, form_html, fallback_action_url, extra_form_data, note, referrer_url): + action_url = self._search_regex( + r'