From 678d0f782d1a5790f3dbe4b19aa82bbea796bfe1 Mon Sep 17 00:00:00 2001 From: xenofem Date: Wed, 24 Jan 2024 02:33:14 -0500 Subject: [PATCH] add configurable locale for metadata --- dlibrary/dlibrary.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index 986a824..5598c1e 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -61,7 +61,7 @@ async def fetch_async(args): thumbnails_dir = args.destdir / 'site' / 'thumbnails' thumbnails_dir.mkdir(parents=True, exist_ok=True) - async with DlsiteAPI() as api: + async with DlsiteAPI(locale=args.locale) as api: for work_path in (args.destdir / 'extract').iterdir(): work_id = work_path.name @@ -459,6 +459,14 @@ parser_extract.add_argument( parser_extract.set_defaults(func=extract) parser_fetch = subparsers.add_parser('fetch', help='fetch metadata and thumbnails') +parser_fetch.add_argument( + '-l', '--locale', + type=str, + default=getenv('DLIBRARY_LOCALE', 'en_US'), + help=('locale to use when requesting metadata (e.g. "ja_JP", "en_US"). ' + 'May still fall back to Japanese if metadata in other languages is unavailable. ' + '(default: $DLIBRARY_LOCALE or en_US)'), +) parser_fetch.set_defaults(func=fetch) parser_collate = subparsers.add_parser(