X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Flynda.py;h=26e84970d49463068f032dcf05afbc03e485e859;hb=1058f56e96316e778ed74ad008949c634a582e84;hp=844ba4dcbfd764c2c13010b7b21e07542eee8c12;hpb=fa27f667c863e81049c8cd55a759b8040710352a;p=youtube-dl.git diff --git a/youtube_dl/extractor/lynda.py b/youtube_dl/extractor/lynda.py index 844ba4dcb..5b458d9bc 100644 --- a/youtube_dl/extractor/lynda.py +++ b/youtube_dl/extractor/lynda.py @@ -1,62 +1,163 @@ from __future__ import unicode_literals import re -import json -from .subtitles import SubtitlesInfoExtractor from .common import InfoExtractor -from ..utils import ExtractorError +from ..compat import ( + compat_HTTPError, + compat_str, + compat_urlparse, +) +from ..utils import ( + ExtractorError, + int_or_none, + urlencode_postdata, +) + + +class LyndaBaseIE(InfoExtractor): + _SIGNIN_URL = 'https://www.lynda.com/signin' + _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'