[seiga] require authentication with 'user_session' cookie (#2372)

Login with username & password would now require entering a 2FA token.

see also 7b009cc893
pull/2396/head
Mike Fährmann 3 years ago
parent 47cf05c4ab
commit fc277fa45f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -124,11 +124,11 @@ Download images; in this case from danbooru via tag search for 'bonocho':
$ gallery-dl "https://danbooru.donmai.us/posts?tags=bonocho"
Get the direct URL of an image from a site that requires authentication:
Get the direct URL of an image from a site supporting authentication with username & password:
.. code:: bash
$ gallery-dl -g -u "<username>" -p "<password>" "https://seiga.nicovideo.jp/seiga/im3211703"
$ gallery-dl -g -u "<username>" -p "<password>" "https://twitter.com/i/web/status/604341487988576256"
Filter manga chapters by language and chapter number:
@ -199,7 +199,7 @@ Username & Password
Some extractors require you to provide valid login credentials in the form of
a username & password pair. This is necessary for
``nijie`` and ``seiga``
``nijie``
and optional for
``aryion``,
``danbooru``,
@ -225,7 +225,7 @@ You can set the necessary information in your configuration file
{
"extractor": {
"seiga": {
"twitter": {
"username": "<username>",
"password": "<password>"
}

@ -356,7 +356,6 @@ Description
Specifying a username and password is required for
* ``nijie``
* ``seiga``
and optional for

@ -521,7 +521,7 @@ Consider all sites to be NSFW unless otherwise known.
<td>Niconico Seiga</td>
<td>https://seiga.nicovideo.jp/</td>
<td>individual Images, User Profiles</td>
<td>Required</td>
<td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td>
</tr>
<tr>
<td>nijie</td>

@ -1,16 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2020 Mike Fährmann
# Copyright 2016-2022 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
"""Extract images from https://seiga.nicovideo.jp/"""
"""Extractors for https://seiga.nicovideo.jp/"""
from .common import Extractor, Message
from .. import text, util, exception
from ..cache import cache
class SeigaExtractor(Extractor):
@ -25,7 +24,9 @@ class SeigaExtractor(Extractor):
self.start_image = 0
def items(self):
self.login()
if not self._check_cookies(("user_session",)):
raise exception.StopExtraction("'user_session' cookie required")
images = iter(self.get_images())
data = next(images)
@ -45,28 +46,6 @@ class SeigaExtractor(Extractor):
url, method="HEAD", allow_redirects=False, notfound="image")
return response.headers["Location"].replace("/o/", "/priv/", 1)
def login(self):
"""Login and set necessary cookies"""
if not self._check_cookies(("user_session",)):
username, password = self._get_auth_info()
self._update_cookies(self._login_impl(username, password))
@cache(maxage=7*24*3600, keyarg=1)
def _login_impl(self, username, password):
if not username or not password:
raise exception.AuthenticationError(
"Username and password required")
self.log.info("Logging in as %s", username)
url = "https://account.nicovideo.jp/api/v1/login"
data = {"mail_tel": username, "password": password}
self.request(url, method="POST", data=data)
if "user_session" not in self.session.cookies:
raise exception.AuthenticationError()
del self.session.cookies["nicosid"]
return self.session.cookies
class SeigaUserExtractor(SeigaExtractor):
"""Extractor for images of a user from seiga.nicovideo.jp"""

@ -265,7 +265,7 @@ AUTH_MAP = {
"ponybooru" : "API Key",
"reddit" : _OAUTH,
"sankaku" : "Supported",
"seiga" : "Required",
"seiga" : _COOKIES,
"seisoparty" : "Supported",
"smugmug" : _OAUTH,
"subscribestar" : "Supported",

Loading…
Cancel
Save