X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2Fextractor%2Flynda.py;h=3084c6dffc9cd3b32ede52906669299807a9ad20;hb=e9fef7ee4e666b60bc7a757391f16e2be76f6cbb;hp=592ed747a47492e13bb939659bc516502b3b4aa0;hpb=aff24732b96b5ec89cb41a05fd132e12c5990caf;p=youtube-dl diff --git a/youtube_dl/extractor/lynda.py b/youtube_dl/extractor/lynda.py index 592ed747a..3084c6dff 100644 --- a/youtube_dl/extractor/lynda.py +++ b/youtube_dl/extractor/lynda.py @@ -1,102 +1,332 @@ from __future__ import unicode_literals import re -import json from .common import InfoExtractor -from ..utils import ExtractorError +from ..compat import ( + compat_str, + compat_urlparse, +) +from ..utils import ( + ExtractorError, + int_or_none, + urlencode_postdata, +) -class LyndaIE(InfoExtractor): +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'