vche / pycliarr

Python client for radarr and sonarr apis. The package provides python client and CLI to use in command line.
MIT License
13 stars 1 forks source link

pycliarr and root folder #30

Closed Pherscho closed 2 years ago

Pherscho commented 2 years ago

First thank you for your work. I wonder if it would be possible somehow to select the root folder when using pycliarr.

I already saw this issue was raised but a bit different: https://github.com/vche/pycliarr/issues/15

Your answer was that pycliarr is just an example client and developers should implement this in their apps. But there are some of us that just use pycliarr because it does almost everything we need for our automation scripts. If implementing the selection is too much just a command line parameter would suffice.

At the moment I use Scalarr for Sonarr because of this issue and I have no solution for Radarr, so for Radarr I use pycliarr and let Radarr save in the wrong folder and then I have to manually move things, but I would prefer to use pycliarr for Sonarr and Radarr in a more straight way..

Thanks again.

vche commented 2 years ago

Hi, indeed this is a different request. My previous point was mostly that the scenario requested was achievable by the user, so add this within the code would be less generic. But setting a "default" root folder as you ask is something that is not possible. yet. your request makes a lot of sense.

I am thinking I could implement the 3 following points:

Would that help with your use cases ? If not, please elaborate what would be helpful. I should be able to find a couple of hours to implement this sometime this week.

Pherscho commented 2 years ago

2 and #3 solve my issue. I guess #1 makes sense for the ones using the library, but I only use the pycliarr client.

Thanks again.

Edit: Scalarr actually lists all the root folders and let you choose one when doing an add. So command line parameter is not the only way to do it. But I would be very happy with any solution that allows me to choose the root folder.

vche commented 2 years ago

I'm open to suggestions to have this on command line. I already list and allow to choose for quality profiles. I can propose an option to do the same indeed, no problem.

But this is interactive (requires human to read output and select). So it will be in addition to the previous option, that allow full automation.

vche commented 2 years ago

Latest commit implements the following:

cli = radarr.RadarrCli("http://192.168.0.199:7878", "xxxx") # no default root id , first entry in folder list will be used res = cli.add_movie(quality=1, imdb_id="tt8115900",) # will use root folder id 2 as first in list cli.default_root_folder_id = 3 print(cli.default_root_folder_id) # 3 res = cli.add_movie(quality=1, imdb_id="tt8115900",) # will use root folder id 3

cli = radarr.RadarrCli("http://192.168.0.199:7878", "xxxx", default_root_folder_id= 2) res = cli.add_movie(quality=1, imdb_id="tt8115900", root_id=3) # will use root folder id 3 res = cli.add_movie(quality=1, imdb_id="tt8115900") # will use root folder id 2 as it's the default

cli = sonarr.SonarrCli("http://192.168.0.199:8989", "xxxx") res = cli.add_serie(quality=4, tvdb_id=424828, root_id=5, language=1)


- CLI command added to list root-folders:
```bash
$ pycliarr -t "http://192.168.0.199:7878" -k "xxxx" radarr root-folders
PyCliarr version 1.0.20
Id  Free       Path
2   4.1TB      /movies
3   71.7GB    /config

$ pycliarr -t "http://192.168.0.199:8989" -k "xxxx" sonarr root-folders
PyCliarr version 1.0.20
Id  Free       Path
5   4.1TB      /tv

$ pycliarr -t "http://192.168.0.199:7878" -k "xxxx" radarr add --imdb tt8115900 -q 1 --root-folder /movies -r 3

$ pycliarr -t "http://192.168.0.199:8989" -k "xxxx" sonarr add -t "south park" -q 4 -l 1 -r 5

$ pycliarr -t "http://192.168.0.199:8989" -k "xxxx" sonarr add --tvdb 424828 -q 4 -l 1 -r /tv


- CLI root folder selection in add commands can be interactive if "auto" is specified:
```bash
$ pycliarr -t "http://192.168.0.199:7878" -k "xxx" radarr add --imdb tt8115900 -q 1 --root-folder /movies -r auto
PyCliarr version 1.0.20
Id  Free       Path
2   4.1TB      /movies
3   71.7GB     /config
Root folder to use (Id):3
...

$ pycliarr -t "http://192.168.0.199:8989" -k "xxxx" sonarr add --tvdb 424828 -q 4 -l 1 -r auto
PyCliarr version 1.0.20
Id  Free       Path
5   4.0TB      /tv
Root folder to use (Id):5
...
vche commented 2 years ago

Release 1.0.21 pusblished, i'll close this in a few days if there's no further issues

Pherscho commented 2 years ago

Adding a movie with the --root-folder is working great.

But I found a problem with the option to list the available root-folders, I get this error:

$ pycliarr -t http://localhost:7878 -k $RADARR_KEY radarr root-folders PyCliarr version 1.0.21 Id Free Path Unexpected error: 'freeSpace'

I am nor sure if it is a wrong dependency in my system. I don't really need that option, but I wanted to let you know about it.

Thanks a lot.

vche commented 2 years ago

No, not an error from your system, this means your radarr does not return the free space, you may have an older version or use v1 protocol (i have version 3.0.9.1549 for instance).

I'll fix that.

Can you please run those commands:

And post the result so that I can validate my theory ?

Thanks.

vche commented 2 years ago

I forgot to add the -j option anyway to display raw data for those who need to parse the results

vche commented 2 years ago

release 1.0.22 adds raw display and support for older version of root folder api:

$ pycliarr -t "http://192.168.0.199:7878" -k "xxxx" sonarr  root-folders
PyCliarr version 1.0.21
Id  Free    Path
5   -          /tv

$ pycliarr -t "http://192.168.0.199:7878" -k "xxxx" sonarr root-folders -j
PyCliarr version 1.0.22
[{'path': '/tv', 'accessible': True, 'freeSpace': 4449728544768, 'unmappedFolders': [], 'id': 5}]

Note: with this release, regarding my previous questions, you can alternatively just run the "root-folders -j" pycliarr command

Pherscho commented 2 years ago

With the new version the option root-folders is working now.

Do you still need the result from those two commands? I assume not. In case you need them, those commands display data I do not feel comfortable pasting here, if you still need them please let me know a way to sent the output to you privately.

But everything is working great from my side, thanks again.

vche commented 2 years ago

The code handles the issue, but the result of those commands would allow me to confirm that the root cause was identified, if not i may need to adapt to handle better backward compatibility.

However i don't need any actual data, feel free to obfuscate it, i just need to see the format. For instance in the dollowing example, none of those values '/tv' '4449728544768' are real, i changed them, and removed the content of "unmappedFolders".

$ pycliarr -t "http://192.168.0.199:7878" -k "xxxx" sonarr root-folders -j
[{'path': '/tv', 'accessible': True, 'freeSpace': 4449728544768, 'unmappedFolders': [], 'id': 5}]

You can simply run pycliarr -t "http://192.168.0.199:7878" -k "xxxx" sonarr root-folders -j replace actual values with some garbage.

But if you are still not comfortable, no worries, i'll assume i'm right until someone else has an issue. I'm reasonably sure the issue comes from you having an older version of radarr/sonarr.

you can also send them to viv@vivc.org directly, but again i don't need any private data :)

Pherscho commented 2 years ago

$ pycliarr -t http://localhost:7878 -k $RADARR_KEY radarr root-folders -j PyCliarr version 1.0.22 [{'path': '/Video/Movies1080p', 'accessible': True, 'unmappedFolders': [], 'id': 1}, {'path': '/Video/Movies4K', 'accessible': True, 'unmappedFolders': [], 'id': 2}, {'path': '/Video/Movies720p', 'accessible': True, 'unmappedFolders': [], 'id': 3}, {'path': '/Video3/Movies', 'accessible': True, 'unmappedFolders': [], 'id': 4}]