mirror of
https://github.com/jo1gi/grawlix.git
synced 2025-12-16 04:09:10 +00:00
Make authentication function simpler
This commit is contained in:
parent
961789d316
commit
8016a29e7e
@ -39,6 +39,9 @@ def get_urls(options) -> list[str]:
|
|||||||
Retrieves all available urls from input arguments
|
Retrieves all available urls from input arguments
|
||||||
- From urls argument
|
- From urls argument
|
||||||
- From file argument
|
- From file argument
|
||||||
|
|
||||||
|
:param options: Cli options
|
||||||
|
:returns: All urls listed in arguments
|
||||||
"""
|
"""
|
||||||
urls = []
|
urls = []
|
||||||
if options.urls:
|
if options.urls:
|
||||||
@ -77,13 +80,12 @@ async def authenticate(source: Source, config: Config, options):
|
|||||||
username, password, library = get_login(source, config, options)
|
username, password, library = get_login(source, config, options)
|
||||||
await source.login(username, password, library=library)
|
await source.login(username, password, library=library)
|
||||||
source.authenticated = True
|
source.authenticated = True
|
||||||
elif source.supports_cookies:
|
if not source.authenticated and source.supports_cookies:
|
||||||
cookie_file = get_cookie_file(options)
|
cookie_file = get_cookie_file(options)
|
||||||
if cookie_file:
|
if cookie_file:
|
||||||
source.load_cookies(cookie_file)
|
source.load_cookies(cookie_file)
|
||||||
else:
|
source.authenticated = True
|
||||||
raise SourceNotAuthenticated
|
if not source.authenticated:
|
||||||
else:
|
|
||||||
raise SourceNotAuthenticated
|
raise SourceNotAuthenticated
|
||||||
|
|
||||||
|
|
||||||
@ -103,10 +105,10 @@ async def main() -> None:
|
|||||||
template: str = args.output or "{title}.{ext}"
|
template: str = args.output or "{title}.{ext}"
|
||||||
await download_with_progress(result, progress, template)
|
await download_with_progress(result, progress, template)
|
||||||
elif isinstance(result, Series):
|
elif isinstance(result, Series):
|
||||||
|
template = args.output or "{series}/{title}.{ext}"
|
||||||
with logging.progress(result.title, source.name, len(result.book_ids)) as progress:
|
with logging.progress(result.title, source.name, len(result.book_ids)) as progress:
|
||||||
for book_id in result.book_ids:
|
for book_id in result.book_ids:
|
||||||
book: Book = await source.download_book_from_id(book_id)
|
book: Book = await source.download_book_from_id(book_id)
|
||||||
template: str = args.output or "{series}/{title}.{ext}"
|
|
||||||
await download_with_progress(book, progress, template)
|
await download_with_progress(book, progress, template)
|
||||||
logging.info("")
|
logging.info("")
|
||||||
except GrawlixError as error:
|
except GrawlixError as error:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user