Merge pull request #3180 from hakatashi/niconico-without-authentication
authorSergey M. <dstftw@gmail.com>
Fri, 4 Jul 2014 15:25:05 +0000 (22:25 +0700)
committerSergey M. <dstftw@gmail.com>
Fri, 4 Jul 2014 15:25:05 +0000 (22:25 +0700)
[niconico] Download without authentication

1  2 
youtube_dl/extractor/niconico.py

index 31f60041cf7c5958f6b770a51e3d6cccee79fc3b,ba7464cb8786e988fdeb5af7b14eeb3c73a07032..d981312711aa31796bb2a33ddf9f5f4fbcd00737
@@@ -38,11 -37,17 +38,17 @@@ class NiconicoIE(InfoExtractor)
          },
      }
  
 -    _VALID_URL = r'^https?://(?:www\.|secure\.)?nicovideo\.jp/watch/([a-z][a-z][0-9]+)(?:.*)$'
 +    _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
  
      def _real_initialize(self):
-         self._login()
+         if self._downloader.params.get('username', None) is not None:
+             self._AUTHENTICATE = True
+         if self._AUTHENTICATE:
+             self._login()
  
      def _login(self):
          (username, password) = self._get_login_info()