python-qBittorrent icon indicating copy to clipboard operation
python-qBittorrent copied to clipboard

In set_file_priority, how to get the file_id?

Open rodrigozanatta opened this issue 3 years ago • 1 comments

Or I am doing something wrong, or the library isn't working?

    qb = Client('http://127.0.0.1:8080/')
    qb.login('name', 'pass')
    for torrent in qb.torrents():
        arqs = qb.get_torrent_files(torrent['hash'])
        for arq in arqs:
            qb.set_file_priority(torrent['hash'], file_id=arq['index'], priority=1) #or 0 or any value

I don't see the changes with this code. How do I get the file_id? Is the index data? There is no other obvious value. What am I doing wrong? Some values change, but it is a little random. So I think the index isn't the correct number.

rodrigozanatta avatar Jul 08 '21 02:07 rodrigozanatta

I discovery the problem! I am making a lot of requests so fast that the program don't have time to change the value. So, I need to put an delay

for arq in arqs:
  qb.set_file_priority(torrent['hash'], file_id=arq['index'], priority=1) #or 0 or any value
  import time
  time.sleep(0.2)

Even this can sometime don't work, so I need to run various for to check if it saved the value! Or make the delay bigger. This bug is not in the python layer, but in the program itself. Where does it process in the program? I didn't find it! If the developer want to open a new bug in the qBittorent, it will help a lot.

rodrigozanatta avatar Jul 08 '21 16:07 rodrigozanatta

Please close the issue, if there is a solution.

DEADSEC-SECURITY avatar Sep 18 '23 18:09 DEADSEC-SECURITY

ok

rodrigozanatta avatar Sep 23 '23 20:09 rodrigozanatta