add configurable locale for metadata

This commit is contained in:
xenofem 2024-01-24 02:33:14 -05:00
parent b437fcc79e
commit 678d0f782d

View file

@ -61,7 +61,7 @@ async def fetch_async(args):
thumbnails_dir = args.destdir / 'site' / 'thumbnails' thumbnails_dir = args.destdir / 'site' / 'thumbnails'
thumbnails_dir.mkdir(parents=True, exist_ok=True) 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(): for work_path in (args.destdir / 'extract').iterdir():
work_id = work_path.name work_id = work_path.name
@ -459,6 +459,14 @@ parser_extract.add_argument(
parser_extract.set_defaults(func=extract) parser_extract.set_defaults(func=extract)
parser_fetch = subparsers.add_parser('fetch', help='fetch metadata and thumbnails') 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_fetch.set_defaults(func=fetch)
parser_collate = subparsers.add_parser( parser_collate = subparsers.add_parser(