X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Flynda.py;h=a98c4c530ec4d62a18b437d5c17275daec5c3dfb;hb=f0d31c624e51322e26889df417152b833549bb75;hp=dd59aa3e6cb3be989a39aa56a95791e4165a8834;hpb=c7f8537dd9752e83661b69e46a4f113222c7a503;p=youtube-dl diff --git a/youtube_dl/extractor/lynda.py b/youtube_dl/extractor/lynda.py index dd59aa3e6..a98c4c530 100644 --- a/youtube_dl/extractor/lynda.py +++ b/youtube_dl/extractor/lynda.py @@ -1,64 +1,203 @@ +from __future__ import unicode_literals + import re -import json from .common import InfoExtractor -from ..utils import ExtractorError - - -class LyndaIE(InfoExtractor): - IE_NAME = u'lynda' - IE_DESC = u'lynda.com videos' - _VALID_URL = r'https?://www\.lynda\.com/[^/]+/[^/]+/\d+/(\d+)-\d\.html' - - _TEST = { - u'url': u'http://www.lynda.com/Bootstrap-tutorials/Using-exercise-files/110885/114408-4.html', - u'file': u'114408.mp4', - u'md5': u'ecfc6862da89489161fb9cd5f5a6fac1', - u"info_dict": { - u'title': u'Using the exercise files', - u'duration': 68 +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'