diff options
author | Adam <oneplusme@users.noreply.github.com> | 2014-08-29 22:32:03 +0100 |
---|---|---|
committer | Adam <oneplusme@users.noreply.github.com> | 2014-08-29 22:32:03 +0100 |
commit | 723e04d0be85fbdbbbda52512f322331d8fda760 (patch) | |
tree | 8773e9857460fc4b70c6febacb20d17827a8523a /youtube_dl | |
parent | 08a36c35693d212405a50b490f7f1828830e60ee (diff) |
Add login support to Crunchyroll extractor
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/crunchyroll.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py index 026a9177e..7642b868e 100644 --- a/youtube_dl/extractor/crunchyroll.py +++ b/youtube_dl/extractor/crunchyroll.py @@ -17,6 +17,7 @@ from ..utils import ( intlist_to_bytes, unified_strdate, clean_html, + urlencode_postdata, ) from ..aes import ( aes_cbc_decrypt, @@ -51,6 +52,24 @@ class CrunchyrollIE(InfoExtractor): '1080': ('80', '108'), } + def _login(self): + (username, password) = self._get_login_info() + if username is None: + return + self.report_login() + login_url = 'https://www.crunchyroll.com/?a=formhandler' + data = urlencode_postdata({ + 'formname': 'RpcApiUser_Login', + 'name': username, + 'password': password, + }) + login_request = compat_urllib_request.Request(login_url, data) + login_request.add_header('Content-Type', 'application/x-www-form-urlencoded') + self._download_webpage(login_request, None, False, 'Wrong login info') + + def _real_initialize(self): + self._login() + def _decrypt_subtitles(self, data, iv, id): data = bytes_to_intlist(data) iv = bytes_to_intlist(iv) |