Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If multiple documents of the same type exist with the same date only one is downloaded #27

Closed
britiscurious opened this issue Apr 20, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@britiscurious
Copy link

britiscurious commented Apr 20, 2022

Description of the bug
I have several "Wertpapierübertrag" documents in my account that are identical in their date, title and subtitle (wherefrom the time is extracted). This is nothing unusual if you have transferred multiple different stocks from another broker to Trade Republic.
Subsequently the destination file paths that are created from these data by pytr are identical and thus only one file will be downloaded whilst the others are skipped.

To Reproduce
Steps to reproduce the behavior:

  1. Ran the command pytr dl_docs .
  2. Noticed that the number of downloaded document did not match the expected number of documents

Expected behavior
All files should be downloaded.
E.g. by adding a number if the file already exists.
Alternatively you could extend the --format FORMAT_STRING argument and provide id or body as variables.
This should be sufficient to create unique file names, e.g.:
--format "{iso_date}{time} {title}{doc_num} - {id}"

Error log

File ... already in queue. Skipping...

Environment

  • OS: MacOS
  • pytr version: 0.1.2

Additional context
Unfortunately these documents do not have a doc_num.

@britiscurious britiscurious added the bug Something isn't working label Apr 20, 2022
@C0D3D3V
Copy link

C0D3D3V commented Apr 21, 2022

Sounds like a problem that should be already fixed. Try pytr 0.1.4

@britiscurious
Copy link
Author

No, it is the same with 0.1.4.

Just have a look into the code.
In the case that I described, iso_date, time, titleText and subtitleText are identical for the different files and doc_type_num is empty then the filepath will be the same for all the actually different files and we end up with "Skipping...".

        filename = self.filename_fmt.format(
            iso_date=iso_date, time=time, title=titleText, subtitle=subtitleText, doc_num=doc_type_num
        )
        if doc_type in ['Kontoauszug', 'Depotauszug']:
            filepath = directory / 'Abschlüsse' / f'{filename}' / f'{doc_type}.pdf'
        else:
            filepath = directory / doc_type / f'{filename}.pdf'

        filepath = sanitize_filepath(filepath, '_', 'auto')

        if filepath in self.filepaths:
            self.log.debug(f'File {filepath} already in queue. Skipping...')
            return
        else:
            self.filepaths.append(filepath)

@marzzzello
Copy link
Collaborator

Yes, I'm working on a fix

@britiscurious
Copy link
Author

#29 is a better than the option to add the doc id to every file name. So only in case of duplicate file paths the id is added automatically. (Using the doc id for a cutom file name format is still possible.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants