X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2Fextractor%2Fniconico.py;h=62d5707fee87302b5f69544f768b1a56a5e3976b;hb=baa708036c64e2dce419b5f0648ee6b84ce2132e;hp=d981312711aa31796bb2a33ddf9f5f4fbcd00737;hpb=165c46690f51585b96a4dff2fac8b4e0c4825231;p=youtube-dl diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py index d98131271..62d5707fe 100644 --- a/youtube_dl/extractor/niconico.py +++ b/youtube_dl/extractor/niconico.py @@ -2,13 +2,13 @@ from __future__ import unicode_literals import re +import json from .common import InfoExtractor from ..utils import ( compat_urllib_parse, compat_urllib_request, compat_urlparse, - ExtractorError, unified_strdate, parse_duration, int_or_none, @@ -40,18 +40,17 @@ class NiconicoIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.|secure\.)?nicovideo\.jp/watch/((?:[a-z]{2})?[0-9]+)' _NETRC_MACHINE = 'niconico' - # Determine whether the downloader uses authentication to download video - _AUTHENTICATE = False + # Determine whether the downloader used authentication to download video + _AUTHENTICATED = False def _real_initialize(self): - if self._downloader.params.get('username', None) is not None: - self._AUTHENTICATE = True - - if self._AUTHENTICATE: - self._login() + self._login() def _login(self): (username, password) = self._get_login_info() + # No authentication to be performed + if not username: + return True # Log in login_form_strs = { @@ -69,6 +68,8 @@ class NiconicoIE(InfoExtractor): if re.search(r'(?i)