pytr-org / pytr

Use TradeRepublic in terminal and mass download all documents
https://pypi.org/project/pytr/
MIT License
382 stars 68 forks source link

Not all Files are downloaded Correctly #10

Closed Tapsel99 closed 2 years ago

Tapsel99 commented 2 years ago
18:22:08 Received all details

18:22:08 Waiting for downloads to complete..

Traceback (most recent call last):

File "C:\Users\name\miniconda3\lib\runpy.py", line 197, in _run_module_as_main

return _run_code(code, main_globals, None,

File "C:\Users\name\miniconda3\lib\runpy.py", line 87, in _run_code

exec(code, run_globals)

File "C:\Users\name\miniconda3\Scripts\pytr.exe\__main__.py", line 7, in <module>

File "C:\Users\name\miniconda3\lib\site-packages\pytr\main.py", line 152, in main

asyncio.get_event_loop().run_until_complete(dl.dl_loop())

File "C:\Users\name\miniconda3\lib\asyncio\base_events.py", line 642, in run_until_complete

return future.result()

File "C:\Users\name\miniconda3\lib\site-packages\pytr\dl.py", line 46, in dl_loop

await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)

File "C:\Users\name\miniconda3\lib\site-packages\pytr\utils.py", line 227, in timelineDetail

dl.work_responses()

File "C:\Users\name\miniconda3\lib\site-packages\pytr\dl.py", line 130, in work_responses

with open(future.filepath, 'wb') as f:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\name\\Documents\\TR-New\\Terms of service - credit cards and wallets \\2021-08-05 2101 Dokumente akzeptiert.pdf'
marzzzello commented 2 years ago

Please use the issue template

C0D3D3V commented 2 years ago

Is your username really name? This could cause Python to interpret the first character of your username \n as an escape sequence for a new line. See https://stackoverflow.com/a/52239952

@marzzzello I would recomend using Pathlib, that should handle such cases without errors.

C0D3D3V commented 2 years ago

I tested it with the username name and it worked without a problem. So you need to give us more informations :D

omegao commented 2 years ago

Hi, I've got the same FileNotFoundError on practically the same document (with a different date in the filename). Every time I run the script, it continued to download a bunch more files (even if the gathered list seems to be the same every time). After about 5 executions, it seems to have downloaded all files (338 files) - except the one Terms of service file. Strangely I can't find the document in the file list in the TR-app (at least not at the timestamp given from the documents name).

What else of information would be helpful?

Greetings!

marzzzello commented 2 years ago

I think the problem is the space at the end of Terms of service - credit cards and wallets. Windows probably doesn't like this path. I'll look into a fix. On Linux it should work anyway

marzzzello commented 2 years ago

@omegao @Tapsel99 please check if version 0.0.14 0.0.15 fixes the issue

omegao commented 2 years ago

Hi @marzzzello, thanks for looking into that issue!

I've just upgraded to 0.0.16 and tried again, but fails already with the very first file:

13:32:22 Received #9  (last) timeline
13:32:22   1/264: Basisinformationen -- Mi. 06.05. um 09:02 Uhr (Europe/Berlin)
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\main.py", line 130, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\dl.py", line 49, in dl_loop
    await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\utils.py", line 237, in timelineDetail
    dl.dl_doc(doc, response['titleText'], response['subtitleText'])
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\dl.py", line 98, in dl_doc
    filepath = sanitize_filepath(filepath, '_', os_name)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pathvalidate\_filepath.py", line 448, in sanitize_filepath
    ).sanitize(file_path, replacement_text)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pathvalidate\_filepath.py", line 84, in sanitize
    self.__fpath_validator.validate_abspath(value)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pathvalidate\_filepath.py", line 255, in validate_abspath
    raise err_object
pathvalidate.error.ValidationError: reason=MALFORMED_ABS_PATH, target-platform=universal, description=an invalid absolute file path (c:\tmp\Basisinformationen über Wertpapiere\2020-05-06 0902 Basisinformationen.pdf) for the platform (universal). to avoid the error, specify an appropriate platform correspond with the path format, or 'auto'.

I've tried with different paths and with/without quotes... no change :|

Tapsel99 commented 2 years ago

i have already reinstalled and updated pytr but still without success. I have censored the name with "Name

(base) C:\Users\name\pytr>pytr dl_docs C:\Usersname\Documents\TradeRepublic-Docs
14:23:11 Found credentials file
14:23:11 Phone: +49***********, PIN: ****
14:23:12 Web session resumed
14:23:12 Logged in
14:23:12 Awaiting #1  timeline
14:23:12 Connecting to websocket ...
14:23:12 Connected to websocket ...
14:23:12 Received #1  timeline, awaiting #2  timeline
14:23:12 Received #2  timeline, awaiting #3  timeline
14:23:12 Received #3  timeline, awaiting #4  timeline
14:23:12 Received #4  timeline, awaiting #5  timeline
14:23:12 Received #5  timeline, awaiting #6  timeline
14:23:12 Received #6  (last) timeline
14:23:13   1/162: Deine Unterlagen -- Di. 29.12. um 14:12 Uhr (Europe/Berlin)
Traceback (most recent call last):
  File "C:\Usersname\miniconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Usersname\miniconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Usersname\miniconda3\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\knamearla\miniconda3\lib\site-packages\pytr\main.py", line 130, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "C:\Usersname\miniconda3\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Usersname\miniconda3\lib\site-packages\pytr\dl.py", line 49, in dl_loop
    await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)
  File "C:\Usersname\miniconda3\lib\site-packages\pytr\utils.py", line 237, in timelineDetail
    dl.dl_doc(doc, response['titleText'], response['subtitleText'])
  File "C:\Usersname\miniconda3\lib\site-packages\pytr\dl.py", line 98, in dl_doc
    filepath = sanitize_filepath(filepath, '_', os_name)
  File "C:\Usersname\miniconda3\lib\site-packages\pathvalidate\_filepath.py", line 442, in sanitize_filepath
    return FilePathSanitizer(
  File "C:\Usersname\miniconda3\lib\site-packages\pathvalidate\_filepath.py", line 84, in sanitize
    self.__fpath_validator.validate_abspath(value)
  File "C:\Usersname\miniconda3\lib\site-packages\pathvalidate\_filepath.py", line 255, in validate_abspath
    raise err_object
pathvalidate.error.ValidationError: reason=MALFORMED_ABS_PATH, target-platform=universal, description=an invalid absolute file path (C:\Usersname\Documents\TradeRepublic-Docs\Kundenvereinbarung\Du und Trade Republic, ein Spitzenteam 1412 Deine Unterlagen.pdf) for the platform (universal). to avoid the error, specify an appropriate platform correspond with the path format, or 'auto'.
marzzzello commented 2 years ago

@Tapsel99 I found the problem, please checkout version 0.0.17 PS: format code with 3 backticks (I've done it for you now):

code

omegao commented 2 years ago

Another error 😨

14:36:47   1/264: Basisinformationen -- Mi. 06.05. um 09:02 Uhr (Europe/Berlin)
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\main.py", line 130, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\dl.py", line 48, in dl_loop
    await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\utils.py", line 237, in timelineDetail
    dl.dl_doc(doc, response['titleText'], response['subtitleText'])
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pytr\dl.py", line 87, in dl_doc
    if os_name == 'nt':
NameError: name 'os_name' is not defined

Should I restart anything after the upgrade or something like that?

marzzzello commented 2 years ago

Sorry I'm stupid please use 0.0.18

omegao commented 2 years ago

Works like a charm! Thanks a lot!