aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2017-01-15 22:51:54 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2017-01-15 22:51:54 +0800
commitdcae7b3fdc6e6812e78c8dba96d671ccf0ab068e (patch)
treed7a3a748606453a6f2aa220041bddf0f3af7a193
parent8e4988f1a21184839dcd23d7133c250a43c5ea58 (diff)
[niconico] Allow login via cookies
Some codes are borrowed from #7968, which is by @jlhg Closes #7968
-rw-r--r--ChangeLog5
-rw-r--r--youtube_dl/extractor/niconico.py18
2 files changed, 12 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index dba18d39b..029d13426 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+version <unreleased>
+
+Extractors
++ [niconico] Support login via cookies (#7968)
+
version 2017.01.14
Core
diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py
index 7e6c594c8..8baac23e4 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -87,8 +87,6 @@ class NiconicoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|secure\.)?nicovideo\.jp/watch/(?P<id>(?:[a-z]{2})?[0-9]+)'
_NETRC_MACHINE = 'niconico'
- # Determine whether the downloader used authentication to download video
- _AUTHENTICATED = False
def _real_initialize(self):
self._login()
@@ -112,8 +110,6 @@ class NiconicoIE(InfoExtractor):
if re.search(r'(?i)<h1 class="mb8p4">Log in error</h1>', login_results) is not None:
self._downloader.report_warning('unable to log in: bad username or password')
return False
- # Successful login
- self._AUTHENTICATED = True
return True
def _real_extract(self, url):
@@ -131,19 +127,19 @@ class NiconicoIE(InfoExtractor):
'http://ext.nicovideo.jp/api/getthumbinfo/' + video_id, video_id,
note='Downloading video info page')
- if self._AUTHENTICATED:
- # Get flv info
- flv_info_webpage = self._download_webpage(
- 'http://flapi.nicovideo.jp/api/getflv/' + video_id + '?as3=1',
- video_id, 'Downloading flv info')
- else:
- raise ExtractorError('Niconico videos now require logging in', expected=True)
+ # Get flv info
+ flv_info_webpage = self._download_webpage(
+ 'http://flapi.nicovideo.jp/api/getflv/' + video_id + '?as3=1',
+ video_id, 'Downloading flv info')
flv_info = compat_urlparse.parse_qs(flv_info_webpage)
if 'url' not in flv_info:
if 'deleted' in flv_info:
raise ExtractorError('The video has been deleted.',
expected=True)
+ elif 'closed' in flv_info:
+ raise ExtractorError('Niconico videos now require logging in',
+ expected=True)
else:
raise ExtractorError('Unable to find video URL')