GChristensen / torrent-add

GNU General Public License v3.0
14 stars 1 forks source link

User categories do not work #6

Closed simonbcn closed 1 year ago

simonbcn commented 1 year ago

Tested in Arc (derived from Chromium) and Google Chrome.

Add Torrent To v0.3

When I add a torrent using the User categories, it sends the torrent but without category. It works fine if I use the Torrent client categories.

GChristensen commented 1 year ago

Hi,

User categories do not assign a category to the torrent, since it obligatory should exist on the client. Although it is possible to create categories on the client from the add-on through the API, there is a little sense in this, since it is preferable to use client-provided categories as a single source of truth. Currently the only way to assign them is to use client categories.

simonbcn commented 1 year ago

I forgot to say that the user categories I have put are the same that exist in the torrent client. The only thing is that I use a reduced version of the client categories.

GChristensen commented 1 year ago

It seems that this is a separate use case (limiting the number of torrent client categories). Need to think how to implement it.

simonbcn commented 1 year ago

Separate use case? I have 8 categories in client and it works well with extension if I use Torrent client categories. But when I use 3 of those categories as User categories it does not work.

simonbcn commented 1 year ago

I have seen the code and I think the solution is very simple:

qbittorrent.js:
....
    async #addTorrent(category, form) {
        try {
            await this.#login();

            const prefs = await this.#fetchJSON("app", "preferences");

            form.append("category", category);

            const apiURL = this.#makeAPIURL("torrents", "add");
            const response = await fetch(apiURL, {method: "POST", body: form});

            if (!response.ok)
                showNotification("Error adding torrent.");
        }
        finally {
            await this.#logout();
        }
    }
....

This way qBittorrent will create the category (and download folder) if it does not exist or use an existing category/folder.

There is no need for the additional processing you currently do when using User Categories in qBittorrent.

GChristensen commented 1 year ago

Yes, probably. But initially the client categories were not processed at all. There were only folder mode, probably it was renamed not correctly. I thing, there should be a folder mode, user category mode, and client category mode.

simonbcn commented 1 year ago

In qBittorrent there is no folder mode (in fact, currently the client does not receive any folders when set to User Categories mode), there are only tags/categories.

GChristensen commented 1 year ago

In the API there is an ability to set plain path without setting a category. This was the initial mode, and it does not require additional configuration, as the use of categories do. I've added the ability to specify user categories in the settings. This will be available in v0.4, when it will be reviewed/approved and available for update in the stores.