[FetLife] Add new extractor - fixed the quantified code issues

This commit is contained in:
motophil 2017-01-22 19:48:59 +01:00
parent 377a2b96dd
commit 88495d44f2

View File

@ -10,6 +10,7 @@ from ..utils import (
class FetLifeIE(JWPlatformBaseIE): class FetLifeIE(JWPlatformBaseIE):
"""InfoExtractor for fetlife.com"""
_VALID_URL = r'https?://fetlife\.com/users/[0-9]+/videos/(?P<id>[0-9]+)' _VALID_URL = r'https?://fetlife\.com/users/[0-9]+/videos/(?P<id>[0-9]+)'
_LOGIN_URL = 'https://fetlife.com/users/sign_in' _LOGIN_URL = 'https://fetlife.com/users/sign_in'
_NETRC_MACHINE = 'fetlife' _NETRC_MACHINE = 'fetlife'
@ -34,6 +35,7 @@ class FetLifeIE(JWPlatformBaseIE):
} }
def _real_initialize(self): def _real_initialize(self):
"""log into fetlife.com"""
(username, password) = self._get_login_info() (username, password) = self._get_login_info()
if (username is None) or (password is None): if (username is None) or (password is None):
raise ExtractorError('No login provided.', expected=True) raise ExtractorError('No login provided.', expected=True)
@ -51,13 +53,14 @@ class FetLifeIE(JWPlatformBaseIE):
request = sanitized_Request(self._LOGIN_URL, urlencode_postdata(login_form)) request = sanitized_Request(self._LOGIN_URL, urlencode_postdata(login_form))
request.add_header('Referer', self._LOGIN_URL) request.add_header('Referer', self._LOGIN_URL)
response = self._download_webpage(request, None, 'Logging in as %s' % username) response = self._download_webpage(request, None, 'Logging in as {}'.format(username))
login_error = self._html_search_regex(r'Login to FetLife', response, 'login error', default=None) login_error = self._html_search_regex(r'Login to FetLife', response, 'login error', default=None)
if login_error: if login_error:
raise ExtractorError('Unable to login.', expected=True) raise ExtractorError('Unable to login.', expected=True)
def _real_extract(self, url): def _real_extract(self, url):
"""extract information from fetlife.com"""
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)