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

Unable to update watched folders using Web API #9679

Closed
SSoft7 opened this Issue Oct 11, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@SSoft7

SSoft7 commented Oct 11, 2018

qBittorrent version and Operating System

v4.1.3 on Ubuntu 16.04

If on linux, libtorrent and Qt version

Using Qbittorrent repository on Ubnutu 16
Package: libtorrent-rasterbar9
Version: 1.1.9+git20180915.8cc93e9855+patched-configure-1ppa1~16.04
I think Qt is not relevant here because I am using nox version.

What is the problem

Unable to update scan_dirs with Web API on v4.1.3.

What is the expected behavior

It should update scan_dirs.

Steps to reproduce

  1. Run following commands.
sudo add-apt-repository ppa:qbittorrent-team/qbittorrent-stable
sudo apt-get update && sudo apt-get install qbittorrent-nox
qbittorrent-nox
  1. Login
    curl --silent --show-error -i -d "username=admin&password=adminadmin" http://localhost:8080/api/v2/auth/login

  2. Grab cookie. and run
    curl --silent --show-error -i --cookie "SID=3133exaykXDX0mUQRDukIr9YUi0EchFY" -d json={"queueing_enabled":false,"scan_dirs":["/home/watch","/home/watch1"],"download_in_scan_dirs":false} http://localhost:8080/api/v2/app/setPreferences

Extra info(if any)

I was trying to set watch directories by manually editing config files but "Downloads\ScanDirsV2" value is encoded. It would be nice, if someone can provide me sample code in python/php/C/bash shell to produce such string OR atleast point me at the correct file on this repo where the encoding is done.

I was able to update other values such as default download directory etc. but scan directory won't update via api. Also i can confirm that the scan_dirs do exist.

Thanks

@SSoft7 SSoft7 closed this Oct 11, 2018

@SSoft7 SSoft7 reopened this Oct 11, 2018

@SSoft7 SSoft7 changed the title from Question to Web API Bug Oct 11, 2018

@SSoft7 SSoft7 changed the title from Web API Bug to [Bug] Web API Oct 11, 2018

@glassez glassez changed the title from [Bug] Web API to Unable to update watched folders using Web API Oct 12, 2018

@glassez glassez added the WebAPI label Oct 12, 2018

@thalieht

This comment has been minimized.

Show comment
Hide comment
@thalieht

thalieht Oct 12, 2018

Contributor

The decoding and parsing is done in https://github.com/qbittorrent/qBittorrent/blob/master/src/base/scanfoldersmodel.cpp#L339 and
https://github.com/qbittorrent/qBittorrent/blob/master/src/base/scanfoldersmodel.cpp#L209

So yeah we use Qt's functions basically. I'm not sure if the following is where it actually happens but here goes: read http://doc.qt.io/qt-5/qvariant.html#value and maybe http://doc.qt.io/qt-5/qvariant.html#toString source code if you want details how it's decoded and http://doc.qt.io/qt-5/qvariant.html#toHash for encoding (not sure at all about this one).

Contributor

thalieht commented Oct 12, 2018

The decoding and parsing is done in https://github.com/qbittorrent/qBittorrent/blob/master/src/base/scanfoldersmodel.cpp#L339 and
https://github.com/qbittorrent/qBittorrent/blob/master/src/base/scanfoldersmodel.cpp#L209

So yeah we use Qt's functions basically. I'm not sure if the following is where it actually happens but here goes: read http://doc.qt.io/qt-5/qvariant.html#value and maybe http://doc.qt.io/qt-5/qvariant.html#toString source code if you want details how it's decoded and http://doc.qt.io/qt-5/qvariant.html#toHash for encoding (not sure at all about this one).

@Piccirello

This comment has been minimized.

Show comment
Hide comment
@Piccirello

Piccirello Oct 13, 2018

Contributor

It seems our WebAPI documentation is outdated regarding expected values for scan_dirs. From my testing, you need to provide the directories as key/value pairs, with the key being the directory path and the value being the location where the torrent should be downloaded.

In your case, the scan_dirs portion of your json should read "scan_dirs":{"/home/watch":1,"/home/watch1":1}, with the 1 indicating the torrents should be downloaded to the default save path (assuming this is your desired preference).

All possible values are:

  • 0 indicating that the torrent should be downloaded directly to the monitored folder
  • 1 indicating qBittorrent's default save path should be used
  • "/path/to/download/to" which is a string value listing a custom path
Contributor

Piccirello commented Oct 13, 2018

It seems our WebAPI documentation is outdated regarding expected values for scan_dirs. From my testing, you need to provide the directories as key/value pairs, with the key being the directory path and the value being the location where the torrent should be downloaded.

In your case, the scan_dirs portion of your json should read "scan_dirs":{"/home/watch":1,"/home/watch1":1}, with the 1 indicating the torrents should be downloaded to the default save path (assuming this is your desired preference).

All possible values are:

  • 0 indicating that the torrent should be downloaded directly to the monitored folder
  • 1 indicating qBittorrent's default save path should be used
  • "/path/to/download/to" which is a string value listing a custom path
@SSoft7

This comment has been minimized.

Show comment
Hide comment
@SSoft7

SSoft7 Oct 14, 2018

@Piccirello Thanks, its working fine now.

SSoft7 commented Oct 14, 2018

@Piccirello Thanks, its working fine now.

@Piccirello Piccirello closed this Oct 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment