X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2Fextractor%2Ffunimation.py;h=0f37ed7863c93da4813a6ac6be2d6402fc7bbd0a;hb=a853427427269549593a0217db203305332ac983;hp=8a65343c59c6a84caec67865ea255cf3d11e8e3f;hpb=f377f44dae78ff6837d9301e7a086dfb1e601df2;p=youtube-dl diff --git a/youtube_dl/extractor/funimation.py b/youtube_dl/extractor/funimation.py index 8a65343c5..0f37ed786 100644 --- a/youtube_dl/extractor/funimation.py +++ b/youtube_dl/extractor/funimation.py @@ -1,8 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -import re - from .common import InfoExtractor from ..utils import ( clean_html, @@ -18,6 +16,8 @@ from ..utils import ( class FunimationIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?funimation\.com/shows/[^/]+/videos/(?:official|promotional)/(?P[^/?#&]+)' + _NETRC_MACHINE = 'funimation' + _TESTS = [{ 'url': 'http://www.funimation.com/shows/air/videos/official/breeze', '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', 'Content-Type': 'application/x-www-form-urlencoded' }) - login = self._download_webpage( + login_page = self._download_webpage( login_request, None, 'Logging in as %s' % username) - if re.search(r'', login) is not None: - raise ExtractorError('Unable to login, wrong username or password.', expected=True) + if any(p in login_page for p in ('funimation.com/logout', '>Log Out<')): + return + error = self._html_search_regex( + r'(?s)]+id=["\']errorMessages["\'][^>]*>(.+?)', + 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): self._login() @@ -145,11 +151,9 @@ class FunimationIE(InfoExtractor): errors.append(format_url) continue if determine_ext(format_url) == 'm3u8': - m3u8_formats = self._extract_m3u8_formats( + formats.extend(self._extract_m3u8_formats( format_url + auth_token, display_id, 'mp4', entry_protocol='m3u8_native', - preference=preference, m3u8_id='%s-hls' % funimation_id, fatal=False) - if m3u8_formats: - formats.extend(m3u8_formats) + preference=preference, m3u8_id='%s-hls' % funimation_id, fatal=False)) else: tbr = int_or_none(self._search_regex( r'-(\d+)[Kk]', format_url, 'tbr', default=None))