Raffaelbdl / kuma-browser

Add-on to use JPDB directly inside Anki
MIT License
8 stars 1 forks source link

issues with importing deck #18

Closed kactaplb closed 1 month ago

kactaplb commented 1 month ago

Hello,

I am facing issues importing decks through the vocablist and api tabs. I am pretty sure I am facing the same problems as described here. https://github.com/Raffaelbdl/kuma-browser/issues/8 Is there any chance you can add a rate limit throttle? I don't care how long it would take to import, nor performance, as long as it finishes. Even a simple sleep would work here lol.

Anki 24.06.3 (d678e393)  (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.22631

Traceback (most recent call last):
  File "urllib3.connectionpool", line 466, in _make_request
  File "urllib3.connectionpool", line 1095, in _validate_conn
  File "urllib3.connection", line 652, in connect
  File "urllib3.connection", line 805, in _ssl_wrap_socket_and_match_hostname
  File "urllib3.util.ssl_", line 465, in ssl_wrap_socket
  File "urllib3.util.ssl_", line 509, in _ssl_wrap_socket_impl
  File "ssl", line 501, in wrap_socket
  File "ssl", line 1074, in _create
  File "ssl", line 1343, in do_handshake
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "urllib3.connectionpool", line 789, in urlopen
  File "urllib3.connectionpool", line 490, in _make_request
urllib3.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:1129)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "requests.adapters", line 589, in send
  File "urllib3.connectionpool", line 843, in urlopen
  File "urllib3.util.retry", line 519, in increment
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='jpdb.io', port=443): Max retries exceeded with url: /api/v1/deck/list-vocabulary (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "path_to_anki\Anki2\addons21\kuma\jpdb_api.py", line 322, in generate_or_update
    notes = api.vocabulary_list(int(deck_id))
  File "path_to_anki\Anki2\addons21\kuma\jpdb_api.py", line 40, in vocabulary_list
    response = requests.post(url, json=payload, headers=headers)
  File "requests.api", line 115, in post
  File "requests.api", line 59, in request
  File "requests.sessions", line 589, in request
  File "requests.sessions", line 703, in send
  File "requests.adapters", line 620, in send
requests.exceptions.SSLError: HTTPSConnectionPool(host='jpdb.io', port=443): Max retries exceeded with url: /api/v1/deck/list-vocabulary (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
'' ['kuma', 0, 'None', '']
JPDB Anki Importer ['541896873', 2023-03-01T22:01, 'None', '']

===IDs of active AnkiWeb add-ons===
541896873

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Raffaelbdl commented 1 month ago

Hi ! Thank you for testing the addon !

I am not sure what is going in your case. Contrary to the original method, this one uses a single API call to collect all the notes in the vocabulary list, which is the line that failed. I cannot limit the rate for this one. The API was in fact used to go around #8 problem.

I will add a simple line in the json next to the jpdb token that you will be able to change manually to control the original method's rate. If the original methods works for you after that, I will push it to master.

Raffaelbdl commented 1 month ago

I have added a straightforward sleep like you suggested, could you try installing the addon from this branch ?

On my side, I also have a lot of difficulty using the original method without a VPN. (in fact I still cannot access the website without one right now :laughing: )

kactaplb commented 1 month ago

PR works great for a moderately large deck ~10 000. Query itself took only maybe a minute with note generation still running. I assume I can change the sleep_time val in vl.json if I need a longer time in the future?

uses a single API call

Ahh I see what happened. I had used the original method > ip banned > api method but too late. Assumed it was using the same query method and didn't want to risk running it again after the unban.

Thanks for the quick PR and addon work!

Raffaelbdl commented 1 month ago

Indeed that seems quite plausible !

The sleep time is the one set in vl.json. I will set it back to 0 and add a section to the README about this issue as it is very common. Thank you for raising it :hugs: