diff --git a/youtube_dl/extractor/roosterteeth.py b/youtube_dl/extractor/roosterteeth.py index 4053747d3..f5b2f560c 100644 --- a/youtube_dl/extractor/roosterteeth.py +++ b/youtube_dl/extractor/roosterteeth.py @@ -1,9 +1,14 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..utils import ( ExtractorError, + int_or_none, + strip_or_none, + unescapeHTML, urlencode_postdata, ) @@ -14,19 +19,17 @@ class RoosterTeethIE(InfoExtractor): _NETRC_MACHINE = 'roosterteeth' _TESTS = [{ 'url': 'http://roosterteeth.com/episode/million-dollars-but-season-2-million-dollars-but-the-game-announcement', + 'md5': 'e2bd7764732d785ef797700a2489f212', 'info_dict': { 'id': '26576', + 'display_id': 'million-dollars-but-season-2-million-dollars-but-the-game-announcement', 'ext': 'mp4', - 'title': 'Million Dollars, But... The Game Announcement', + 'title': 'Million Dollars, But...: Million Dollars, But... The Game Announcement', + 'description': 'md5:0cc3b21986d54ed815f5faeccd9a9ca5', 'thumbnail': 're:^https?://.*\.png$', - 'description': 'Introducing Million Dollars, But... The Game! Available for pre-order now at www.MDBGame.com ', - 'creator': 'Rooster Teeth', 'series': 'Million Dollars, But...', 'episode': 'Million Dollars, But... The Game Announcement', - 'episode_id': '26576', - }, - 'params': { - 'skip_download': True, # m3u8 downloads + 'comment_count': int, }, }, { 'url': 'http://achievementhunter.roosterteeth.com/episode/off-topic-the-achievement-hunter-podcast-2016-i-didn-t-think-it-would-pass-31', @@ -40,73 +43,106 @@ class RoosterTeethIE(InfoExtractor): }, { 'url': 'http://theknow.roosterteeth.com/episode/the-know-game-news-season-1-boring-steam-sales-are-better', 'only_matching': True, + }, { + # only available for FIRST members + 'url': 'http://roosterteeth.com/episode/rt-docs-the-world-s-greatest-head-massage-the-world-s-greatest-head-massage-an-asmr-journey-part-one', + 'only_matching': True, }] def _login(self): (username, password) = self._get_login_info() - if username is None or password is None: - return False + if username is None: + return - # token is required to authenticate request - login_page = self._download_webpage(self._LOGIN_URL, None, 'Getting login token', 'Unable to get login token') + login_page = self._download_webpage( + self._LOGIN_URL, None, + note='Downloading login page', + errnote='Unable to download login page') login_form = self._hidden_inputs(login_page) + login_form.update({ 'username': username, 'password': password, }) - login_payload = urlencode_postdata(login_form) - - # required for proper responses - login_headers = { - 'Referer': self._LOGIN_URL, - } login_request = self._download_webpage( self._LOGIN_URL, None, note='Logging in as %s' % username, - data=login_payload, - headers=login_headers) + data=urlencode_postdata(login_form), + headers={ + 'Referer': self._LOGIN_URL, + }) - if 'Authentication failed' in login_request: - raise ExtractorError( - 'Login failed (invalid username/password)', expected=True) + if not any(re.search(p, login_request) for p in ( + r'href=["\']https?://(?:www\.)?roosterteeth\.com/logout"', + r'>Sign Out<')): + error = self._html_search_regex( + r'(?s)