diff --git a/README.rst b/README.rst index 8e9d6581..3249d569 100644 --- a/README.rst +++ b/README.rst @@ -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 "" -p "" "https://seiga.nicovideo.jp/seiga/im3211703" + $ gallery-dl -g -u "" -p "" "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": "", "password": "" } diff --git a/docs/configuration.rst b/docs/configuration.rst index d4fadf7e..31ca72df 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -356,7 +356,6 @@ Description Specifying a username and password is required for * ``nijie`` - * ``seiga`` and optional for diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 31388824..e2d6e416 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -521,7 +521,7 @@ Consider all sites to be NSFW unless otherwise known. Niconico Seiga https://seiga.nicovideo.jp/ individual Images, User Profiles - Required + Cookies nijie diff --git a/gallery_dl/extractor/seiga.py b/gallery_dl/extractor/seiga.py index bf38a772..22c94870 100644 --- a/gallery_dl/extractor/seiga.py +++ b/gallery_dl/extractor/seiga.py @@ -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""" diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 3fe86752..d2df6bb3 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -265,7 +265,7 @@ AUTH_MAP = { "ponybooru" : "API Key", "reddit" : _OAUTH, "sankaku" : "Supported", - "seiga" : "Required", + "seiga" : _COOKIES, "seisoparty" : "Supported", "smugmug" : _OAUTH, "subscribestar" : "Supported",