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

Return Torrent hash or TorrentDictionary from Client.torrents.add() and Support Additional Actions when Adding a Torrent #74

Open
unsocial-bleach opened this issue Jan 7, 2022 · 3 comments
Labels
enhancement New feature or request upstream Requires updates upstream

Comments

@unsocial-bleach
Copy link

I want to enable super seeding at the time that I add a torrent via an additional parameter to qbt_client.torrents_add(urls='...'), like qbt_client.torrents_add(urls='...', enable_super_seeding=True).

I don't want to have to lookup the torrent hash, and make a separate request to enable super seeding. Using qbt_client.set_super_seeding(...) is less convenient.

I understand that this may mean straying from implementing the existing API calls exactly, but I think that the UX benefit of this Python library will make it worth it.

@rmartin16
Copy link
Owner

Hello @unsocial-bleach,
This is a probably a reasonable request based on your use-case.

However, as in #29, it cannot be guaranteed this client can reliably determine which torrent will be added to qBittorrent when qbt_client.torrents_add() is invoked. That is, from an arbitrary URL, file, or binary blob that torrents_add() can accept, it is non-trivial to determine which torrent was actually added to qBittorrent....if one or more was added at all.

Although, given enough information in a specific example, it would normally be trivial to determine the actual torrent; it's just difficult to generalize to any possible case. I'm definitely open to ideas I may be overlooking.

I think ideally the qBittorrent team would implement qbittorrent/qBittorrent#4879 so that their torrents/add method would return more information about what torrents were added during the call; this would trivialize performing more complex operations on the added torrent.

Alternatively, thinking out loud, it'd probably be technically possible for this client to request a corresponding torrent hash from users for each torrent to be added by qbt_client.torrents_add().....however, that starts to feel particularly kludgy and likely even error-prone.

As you've stated, though, it should be fairly straightforward at least to write a small wrapper for this client to add the torrent and set additional options such as super seeding....albeit with at least two more API calls...

@unsocial-bleach
Copy link
Author

All reasonable points! I guess for now, we'll wait on qbittorrent/qBittorrent#4879.

@rmartin16 rmartin16 added upstream Requires updates upstream enhancement New feature or request labels Jan 28, 2022
@rmartin16 rmartin16 changed the title Feature Request: add a parameter to qbit_client.add_torrents to enable super seeding Return Torrent hash or TorrentDictionary from Client.torrents.add() and Support Additional Actions when Adding a Torrent May 22, 2023
@commonelk
Copy link

commonelk commented Dec 22, 2023

One can create a temporary category, assign it to the torrents during the initial qbt_client.torrents_add(...) call, use said category to retrieve the hashes, and then remove the temporary category, like so:

temp_cat = "..."
qbt_client.torrents_add(urls=magnet_urls, category=temp_cat)
hashes = [ torrent_info.hash for torrent_info in qbt_client.torrents_info(category=temp_cat) ]
qbt_client.torrent_categories.remove_categories(categories=temp_cat)

I'd further suggest randomly generating the category and or ensuring it is unique (e.g. compare with qbt_client.torrents_categories()) in the off-chance that the temp_cat is already an existing category. Of course, the need for this precaution depends on one's use-case.

There's likely a better method of retrieving hashes from added torrents, but I figured I'd leave this here in case it helps anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream Requires updates upstream
Projects
None yet
Development

No branches or pull requests

3 participants