X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=youtube_dl%2Fextractor%2Flynda.py;h=da94eab561b91d6b70675911e432b5750d5d5b04;hb=a22b2fd19bd8c08d50f884d1903486d4f00f76ec;hp=33f34f4e9bdda2aa034dd4f46ef3299478f181ec;hpb=136db7881b4ed820182697f0f5bd7c114aa70f46;p=youtube-dl diff --git a/youtube_dl/extractor/lynda.py b/youtube_dl/extractor/lynda.py index 33f34f4e9..da94eab56 100644 --- a/youtube_dl/extractor/lynda.py +++ b/youtube_dl/extractor/lynda.py @@ -1,95 +1,213 @@ from __future__ import unicode_literals import re -import json -from .subtitles import SubtitlesInfoExtractor from .common import InfoExtractor +from ..compat import ( + compat_HTTPError, + compat_str, + compat_urlparse, +) from ..utils import ( - compat_urllib_parse, - compat_urllib_request, ExtractorError, int_or_none, - compat_str, + urlencode_postdata, ) -class LyndaIE(SubtitlesInfoExtractor): +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'