mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
[funimation] Improve login
This commit is contained in:
parent
c03943f394
commit
0014ffa829
|
@ -1,8 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
|
@ -18,6 +16,8 @@ from ..utils import (
|
||||||
class FunimationIE(InfoExtractor):
|
class FunimationIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?funimation\.com/shows/[^/]+/videos/(?:official|promotional)/(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?://(?:www\.)?funimation\.com/shows/[^/]+/videos/(?:official|promotional)/(?P<id>[^/?#&]+)'
|
||||||
|
|
||||||
|
_NETRC_MACHINE = 'funimation'
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.funimation.com/shows/air/videos/official/breeze',
|
'url': 'http://www.funimation.com/shows/air/videos/official/breeze',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -62,10 +62,16 @@ class FunimationIE(InfoExtractor):
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 5.2; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 5.2; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
})
|
})
|
||||||
login = self._download_webpage(
|
login_page = self._download_webpage(
|
||||||
login_request, None, 'Logging in as %s' % username)
|
login_request, None, 'Logging in as %s' % username)
|
||||||
if re.search(r'<meta property="og:url" content="http://www.funimation.com/login"/>', login) is not None:
|
if any(p in login_page for p in ('funimation.com/logout', '>Log Out<')):
|
||||||
raise ExtractorError('Unable to login, wrong username or password.', expected=True)
|
return
|
||||||
|
error = self._html_search_regex(
|
||||||
|
r'(?s)<div[^>]+id=["\']errorMessages["\'][^>]*>(.+?)</div>',
|
||||||
|
login_page, 'error messages', default=None)
|
||||||
|
if error:
|
||||||
|
raise ExtractorError('Unable to login: %s' % error, expected=True)
|
||||||
|
raise ExtractorError('Unable to log in')
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self._login()
|
self._login()
|
||||||
|
|
Loading…
Reference in a new issue