diff --git a/pytr/dl.py b/pytr/dl.py index 73c098d..f9de58d 100644 --- a/pytr/dl.py +++ b/pytr/dl.py @@ -12,7 +12,16 @@ class DL: - def __init__(self, tr, output_path, filename_fmt, since_timestamp=0, history_file='pytr_history', max_workers=8): + def __init__( + self, + tr, + output_path, + filename_fmt, + since_timestamp=0, + history_file='pytr_history', + max_workers=8, + universal_filepath=False, + ): ''' tr: api object output_path: name of the directory where the downloaded files are saved @@ -24,6 +33,7 @@ def __init__(self, tr, output_path, filename_fmt, since_timestamp=0, history_fil self.history_file = self.output_path / history_file self.filename_fmt = filename_fmt self.since_timestamp = since_timestamp + self.universal_filepath = universal_filepath requests_session = session() if self.tr._weblogin: @@ -117,8 +127,12 @@ def dl_doc(self, doc, titleText, subtitleText, subfolder=None): filepath = directory / doc_type / f'{filename}.pdf' filepath_with_doc_id = directory / doc_type / f'{filename_with_doc_id}.pdf' - filepath = sanitize_filepath(filepath, '_', 'auto') - filepath_with_doc_id = sanitize_filepath(filepath_with_doc_id, '_', 'auto') + if self.universal_filepath: + filepath = sanitize_filepath(filepath, '_', 'universal') + filepath_with_doc_id = sanitize_filepath(filepath_with_doc_id, '_', 'universal') + else: + filepath = sanitize_filepath(filepath, '_', 'auto') + filepath_with_doc_id = sanitize_filepath(filepath_with_doc_id, '_', 'auto') if filepath in self.filepaths: self.log.debug(f'File {filepath} already in queue. Append document id {doc_id}...') diff --git a/pytr/main.py b/pytr/main.py index e62f823..0fa0799 100644 --- a/pytr/main.py +++ b/pytr/main.py @@ -91,6 +91,7 @@ def formatter(prog): parser_dl_docs.add_argument( '--workers', help='Number of workers for parallel downloading', metavar='WORKERS', default=8, type=int ) + parser_dl_docs.add_argument('--universal', help='Platform independent file names', action='store_true') # portfolio info = 'Show current portfolio' parser_cmd.add_parser( @@ -202,6 +203,7 @@ def main(): args.format, since_timestamp=since_timestamp, max_workers=args.workers, + universal_filepath=args.universal, ) asyncio.get_event_loop().run_until_complete(dl.dl_loop()) elif args.command == 'set_price_alarms':