JohnDoee / autotorrent2

Cross-seed matching and torrent lifecycle tool
https://johndoee.github.io/autotorrent2/
MIT License
142 stars 10 forks source link

Error on torrent add: KeyError: 'create_subfolder_enabled' #9

Closed Tr4il closed 2 years ago

Tr4il commented 2 years ago

Adding a torrent to my qbittorrent instance gives me the following:

Traceback (most recent call last):
  File "/home/user/.autotorrent/bin/at2", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/autotorrent/__main__.py", line 521, in add
    client.add(
  File "/home/user/.autotorrent/lib/python3.10/site-packages/libtc/clients/qbittorrent.py", line 137, in add
    create_subfolder_enabled = self._check_create_subfolder_enabled()
  File "/home/user/.autotorrent/lib/python3.10/site-packages/libtc/clients/qbittorrent.py", line 117, in _check_create_subfolder_enabled
    return self.call("get", "/api/v2/app/preferences").json()[
KeyError: 'create_subfolder_enabled'

The link does get made and the file is accessible there, but it does not get added to the client. I have the subfolder setting in qBittorrent set to "Original", if that matters? Thanks!

JohnDoee commented 2 years ago

Without that option you cannot actually know where qBittorrent will download data when you add it. They didn't get around to adding the preference until around end of 2018.

Which version of qBittorrent are you running?

Tr4il commented 2 years ago

qBittorrent version 4.4.3.1, running the hotio docker container. I tested it with all three options in that setting, create subfolder, don't create subfolder and original. Getting the same error. I also tested a different torrent file, same error. verbose log:

DEBUG:urllib3.connectionpool:228:Starting new HTTP connection (1): localhost:60000
DEBUG:urllib3.connectionpool:456:http://localhost:60000 "GET /api/v2/torrents/info?filter=all HTTP/1.1" 403 9
DEBUG:urllib3.connectionpool:456:http://localhost:60000 "POST /api/v2/auth/login HTTP/1.1" 200 3
DEBUG:urllib3.connectionpool:456:http://localhost:60000 "GET /api/v2/torrents/info?filter=all HTTP/1.1" 200 45960
Matching 1 torrent
DEBUG:autotorrent.db:174:Doing query: 'SELECT name, path, size, normalized_name, unsplitable_root FROM files WHERE normalized_name = ? AND size = ?' with args: ['$FILE.mkv', 2465167109]
DEBUG:autotorrent.utils:307:Piece calculation start_piece: 0 start_offset: 0 first_complete_piece: 0 end_piece: 1175 end_offset: 1013509 last_complete_piece: 1174
DEBUG:autotorrent.utils:307:Piece calculation start_piece: 0 start_offset: 0 first_complete_piece: 0 end_piece: 1175 end_offset: 1013509 last_complete_piece: 1175
DEBUG:autotorrent.utils:307:Piece calculation start_piece: 0 start_offset: 0 first_complete_piece: 0 end_piece: 1175 end_offset: 1013509 last_complete_piece: 1175
DEBUG:autotorrent.utils:307:Piece calculation start_piece: 0 start_offset: 0 first_complete_piece: 0 end_piece: 1175 end_offset: 1013509 last_complete_piece: 1175
DEBUG:urllib3.connectionpool:456:http://localhost:60000 "GET /api/v2/app/preferences HTTP/1.1" 200 1678
Traceback (most recent call last):
  File "/home/user/.autotorrent/bin/at2", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.autotorrent/lib/python3.10/site-packages/autotorrent/__main__.py", line 521, in add
    client.add(
  File "/home/user/.autotorrent/lib/python3.10/site-packages/libtc/clients/qbittorrent.py", line 137, in add
    create_subfolder_enabled = self._check_create_subfolder_enabled()
  File "/home/user/.autotorrent/lib/python3.10/site-packages/libtc/clients/qbittorrent.py", line 117, in _check_create_subfolder_enabled
    return self.call("get", "/api/v2/app/preferences").json()[
KeyError: 'create_subfolder_enabled'

Edit: Could it have something to do with the store path setting in the at2 config? I have it set like the following: store_path = "/mnt/unionfs/downloads/torrents/qbittorrent/seeding/{torrent_name}"

JohnDoee commented 2 years ago

It's not related to anything you do, it's about if torrents are saved to a folder with the same name as the torrent or not.

qBittorrent team modified how the option works without any warning and did not document it anywhere.

Autotorrent really needs to know where data is saved to make sure everything has the correct path. So I have to check how qBittorrent is configured.

JohnDoee commented 2 years ago

This should work now with all versions of qBittorrent I could get my hand on easily in 1.0.3.