Giter Club home page Giter Club logo

Comments (7)

rmartin16 avatar rmartin16 commented on September 17, 2024 1

Hmm....you should be able to rename the top directory of the torrent with the torrents_rename_folder command; that even changed the directory on the disk for me. It's possible qBittorrent is encountering some sort of error; perhaps their log would capture that.

Further, though, I also will usually do things in qBittorrent's WebUI to understand how they use the API for different tasks. You can open up the dev tools with F12 or some menu, select the Network tab and there you can see the API calls being made to qBittorrent when you rename things. That may help clarify what's going wrong as well.

You can even get verbose logging out of this client if you initialize it like this:

import logging
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] {%(name)s:%(lineno)d} %(levelname)s - %(message)s')

import qbittorrentapi
client = qbittorrentapi.Client(host='localhost:8080', username="admin", password="adminadmin", VERBOSE_RESPONSE_LOGGING=True)

The torrents_rename_file command will allow you rename files. I used this command for a single file torrent:

client.torrents_rename_folder(old_path="kubuntu-21.04-desktop-amd64.iso", new_path="new_kubuntu-21.04-desktop-amd64.iso", torrent_hash="d65d07329264aecb2d2be7a6c0e86b6613b2a600")

from qbittorrent-api.

rmartin16 avatar rmartin16 commented on September 17, 2024

Hello @farmwald,
Here's an example with a dummy torrent I just made.

Files in torrent
image

for file in client.torrents_files("35ea45daf588289aba0dee455eff33246db58d4b"):
     pprint(dict(file))

{'availability': 0,
 'id': 0,
 'index': 0,
 'is_seed': False,
 'name': 'rootdir/dir1/file1',
 'piece_range': [0, 0],
 'priority': 1,
 'progress': 0,
 'size': 6}
{'availability': 0,
 'id': 1,
 'index': 1,
 'name': 'rootdir/dir2/file2',
 'piece_range': [0, 0],
 'priority': 1,
 'progress': 0,
 'size': 6}

Rename dir1 folder to dir1new

client.torrents_rename_folder(old_path="rootdir/dir1", new_path="rootdir/dir1new", torrent_hash="35ea45daf588289aba0dee455eff33246db58d4b")

Updated Files in torrent
image

for file in client.torrents_files("35ea45daf588289aba0dee455eff33246db58d4b"):
     pprint(dict(file))

{'availability': 0,
 'id': 0,
 'index': 0,
 'is_seed': False,
 'name': 'rootdir/dir1new/file1',
 'piece_range': [0, 0],
 'priority': 1,
 'progress': 0,
 'size': 6}
{'availability': 0,
 'id': 1,
 'index': 1,
 'name': 'rootdir/dir2/file2',
 'piece_range': [0, 0],
 'priority': 1,
 'progress': 0,
 'size': 6}

Hope that helps. Let me know if you run into more issues.

from qbittorrent-api.

farmwald avatar farmwald commented on September 17, 2024

This is very helpful, but I'm still having problems with two different cases.

In both cases, I'm trying to rename the "top" file or directory, i.e. "rootdir" in your example.
In one case, rootdir is actually a directory, and I want to change its name (to match a modified torrent name). It sort of works,
in that qbittorrent changes the name under content in the qbittorrent gui, but doesn't rename the actual folder. This leaves the torrent in an errored state. The old dirname contains non-ascii characters which may be relevant. I can try it with a more standard name.

In the other case, I'm trying to rename a single file at the top level, no directories involved. I've tried both torrent_rename_file and torrent_rename_folder. Both fail for me. rename_file fails complaining about new_path and old_path - I've tried
path=".",, path="", and not adding them (path=None) - all throw errors.
torrent_rename_folder throws an error that no such directory exists.

Thanks for the help.

from qbittorrent-api.

rmartin16 avatar rmartin16 commented on September 17, 2024

Another thought is to confirm the version of qBittorrent you're using. Some package managers have quite old versions.

from qbittorrent-api.

farmwald avatar farmwald commented on September 17, 2024

I'm on either 4.4.0 or 4.5.0, depending.
It sounds like the problems are mine, so let me generate some simple test cases and also check the log.

from qbittorrent-api.

farmwald avatar farmwald commented on September 17, 2024

I had a bug - seems to work just fine.
Thanks.

from qbittorrent-api.

rmartin16 avatar rmartin16 commented on September 17, 2024

Good deal; glad you got it worked out.

from qbittorrent-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.