haijeploeg / excludarr

Excludarr manages your libraries in Radarr/Sonarr. It keeps track of your library and checks if your movies and series are also available on a configured streaming provider. It can exclude the movies and series that are available on a configured streaming provider. But it can also re-add movies and series if they are not streaming anymore.
MIT License
204 stars 12 forks source link

Error with locale #50

Closed faulander closed 2 years ago

faulander commented 2 years ago

harald@europa:~$ excludarr sonarr exclude -a delete -d Traceback (most recent call last): File "/home/harald/.local/bin/excludarr", line 8, in <module> sys.exit(cli()) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/main.py", line 68, in cli app(prog_name="excludarr") File "/home/harald/.local/lib/python3.9/site-packages/typer/main.py", line 214, in __call__ return get_command(self)(*args, **kwargs) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/harald/.local/lib/python3.9/site-packages/typer/main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "/home/harald/.local/lib/python3.9/site-packages/excludarr/commands/sonarr.py", line 65, in exclude sonarr = SonarrActions( File "/home/harald/.local/lib/python3.9/site-packages/excludarr/core/sonarr_actions.py", line 18, in __init__ self.justwatch_client = JustWatch(locale) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/modules/justwatch/justwatch.py", line 32, in __init__ self.locale = self._get_full_locale(locale) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/modules/justwatch/justwatch.py", line 83, in _get_full_locale valid_locale = any([True for i in jw_locales if i["full_locale"] == locale]) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/modules/justwatch/justwatch.py", line 83, in <listcomp> valid_locale = any([True for i in jw_locales if i["full_locale"] == locale]) TypeError: string indices must be integers

Running on Ubuntu 20, locale set to "DE" and "de_DE", both throw the same error.

haijeploeg commented 2 years ago

Hi, can you please fill in the issue template? I need to know where exactly the command fails. And run the command in debug mode (excludarr --debug sonarr exclude -a delete -d)

faulander commented 2 years ago

Describe the bug whatever excludar command i run, i get the same error

To Reproduce Steps to reproduce the behavior: Any excludar command.

Expected behavior A clear and concise description of what you expected to happen.

Versions

  1. OS Version: Ubuntu 20.04
  2. Excludarr version: 1.0.5
  3. Python version: 3.9

Debug logging harald@europa:~$ excludarr --debug sonarr exclude -a delete -d [2022-01-21 17:17:53] - Starting Excludarr v1.0.5 [2022-01-21 17:17:53] - Got sonarr as subcommand [2022-01-21 17:17:53] - Reading configuration file [2022-01-21 17:17:53] - Determining which configfile to use [2022-01-21 17:17:53] - Configfile to use: /etc/excludarr/excludarr.yml [2022-01-21 17:17:53] - Reading configfile: /etc/excludarr/excludarr.yml [2022-01-21 17:17:53] - Read the following configuration: {'general': {'fast_search': True, 'locale': 'de_DE', 'providers': ['Netflix', 'Amazon Prime Video']}, 'tmdb': {'api_key': ''}, 'sonarr': {'url': 'http://192.168.42.167:8989', 'api_key': '', 'verify_ssl': False, 'exclude': ['Luther', 'Sherlock']}} [2022-01-21 17:17:53] - Got exclude as subcommand [2022-01-21 17:17:53] - Got CLI values for -p, --provider option: [2022-01-21 17:17:53] - Got CLI values for -l, --locale option: None [2022-01-21 17:17:53] - Got CLI values for -a, --action option: delete [2022-01-21 17:17:53] - Got CLI values for -d, --delete option: True [2022-01-21 17:17:53] - Got CLI values for -e, --exclusion option: False [2022-01-21 17:17:53] - Got CLI values for -y, --yes option: False [2022-01-21 17:17:53] - Got CLI values for --progress option: False [2022-01-21 17:17:53] - Initializing PySonarr [2022-01-21 17:17:53] - Initializing JustWatch API with locale: de_DE Traceback (most recent call last): File "/home/harald/.local/bin/excludarr", line 8, in sys.exit(cli()) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/main.py", line 68, in cli app(prog_name="excludarr") File "/home/harald/.local/lib/python3.9/site-packages/typer/main.py", line 214, in call return get_command(self)(*args, kwargs) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/harald/.local/lib/python3.9/site-packages/click/core.py", line 754, in invoke return __callback(args, kwargs) File "/home/harald/.local/lib/python3.9/site-packages/typer/main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "/home/harald/.local/lib/python3.9/site-packages/excludarr/commands/sonarr.py", line 65, in exclude sonarr = SonarrActions( File "/home/harald/.local/lib/python3.9/site-packages/excludarr/core/sonarr_actions.py", line 18, in init self.justwatch_client = JustWatch(locale) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/modules/justwatch/justwatch.py", line 32, in init self.locale = self._get_full_locale(locale) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/modules/justwatch/justwatch.py", line 83, in _get_full_locale valid_locale = any([True for i in jw_locales if i["full_locale"] == locale]) File "/home/harald/.local/lib/python3.9/site-packages/excludarr/modules/justwatch/justwatch.py", line 83, in valid_locale = any([True for i in jw_locales if i["full_locale"] == locale]) TypeError: string indices must be integers

Additional context Add any other context about the problem here.

haijeploeg commented 2 years ago

That is really strange, It looks like you are not getting proper output returned from JustWatch. Can you execute the following command in your terminal and report back to me?

curl -L -X GET https://apis.justwatch.com/content/locales/state
faulander commented 2 years ago

seems there is an auth error: harald@europa:~$ curl -L -X GET https://apis.justwatch.com/content/locales/state

403 Forbidden

Error: Forbidden

Your client does not have permission to get URL /content/locales/state from this server.

haijeploeg commented 2 years ago

Hi, it seems that your IP is maybe in a blocklist. Can you answer these questions?

curl 'https://apis.justwatch.com/content/locales/state' \
-X 'GET' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Origin: https://www.justwatch.com' \
-H 'Host: apis.justwatch.com' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15'
faulander commented 2 years ago

Yes, i am running that machine behind a VPN, it's a console only machine, so i can only curl. You're right, the homepage gives the same error. Strange, never had that problem before. ExpressVPN is what i am using. The curl with the added agent and options didn't work either.

It seems i need to run Excludarr from anyother machine then :/

faulander commented 2 years ago

On my macbook i get a different error: And yes: Sonarr is reachable with this url and the apikey is correct aswell.

I might know the reason: Do you delete the files on harddisk by excludarr or do you let sonarr delete the files? excludarr has no access to the files on a system level. Does it need it?

❯ excludarr --debug sonarr exclude -a delete -d
[2022-01-22 19:58:48] - Starting Excludarr v1.0.6
[2022-01-22 19:58:48] - Got sonarr as subcommand
[2022-01-22 19:58:48] - Reading configuration file
[2022-01-22 19:58:48] - Determining which configfile to use
[2022-01-22 19:58:48] - Configfile to use: ./.excludarr.yml
[2022-01-22 19:58:48] - Reading configfile: ./.excludarr.yml
[2022-01-22 19:58:48] - Read the following configuration: {'general': {'fast_search': True, 'locale': 'de_DE', 'providers': ['Netflix', 'Amazon Prime Video']}, 'sonarr': {'url': 'http://192.168.42.167:8989', 'api_key': '<REDACTED>', 'verify_ssl': False, 'exclude': ['Luther', 'Sherlock']}}
[2022-01-22 19:58:48] - Got exclude as subcommand
[2022-01-22 19:58:48] - Got CLI values for -p, --provider option:
[2022-01-22 19:58:48] - Got CLI values for -l, --locale option: None
[2022-01-22 19:58:48] - Got CLI values for -a, --action option: delete
[2022-01-22 19:58:48] - Got CLI values for -d, --delete option: True
[2022-01-22 19:58:48] - Got CLI values for -e, --exclusion option: False
[2022-01-22 19:58:48] - Got CLI values for -y, --yes option: False
[2022-01-22 19:58:48] - Got CLI values for --progress option: False
[2022-01-22 19:58:48] - Initializing PySonarr
[2022-01-22 19:58:48] - Initializing JustWatch API with locale: de_DE
[2022-01-22 19:58:49] - Getting all the series from Sonarr
Traceback (most recent call last):
  File "/Users/haraldfauland/Applications/excludarr/venv/bin/excludarr", line 8, in <module>
    sys.exit(cli())
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/main.py", line 68, in cli
    app(prog_name="excludarr")
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/commands/sonarr.py", line 69, in exclude
    series_to_exclude = sonarr.get_series_to_exclude(
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/core/sonarr_actions.py", line 160, in get_series_to_exclude
    sonarr_series = self.sonarr_client.serie.get_all_series()
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/modules/pysonarr/v3/serie.py", line 13, in get_all_series
    return self.client.http_get(self.serie_path)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/modules/pysonarr/__init__.py", line 74, in http_get
    return self.http_request("get", path, params=params)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/modules/pysonarr/__init__.py", line 65, in http_request
    return self._filter_api_error(result)
  File "/Users/haraldfauland/Applications/excludarr/venv/lib/python3.9/site-packages/excludarr/modules/pysonarr/__init__.py", line 49, in _filter_api_error
    raise SonarrMovieNotFound("Serie not found")
excludarr.modules.pysonarr.exceptions.SonarrMovieNotFound: Serie not found
haijeploeg commented 2 years ago

That means the API of sonarr returns a 404 not found message. What version of sonarr are you using? Excludarr only sends API calls. It does none of the deleting itself. It let sonarr handles that. But Excludarr is only at the start of its run and has just tried to get all the series present in Sonarr. You need to have Sonarr V3 installed in order to let it work with Excludarr. Can you verify this?

faulander commented 2 years ago

aaah, no i am running sonarr V2, didn't see in the requirements that Sonarr V3 is needed.

haijeploeg commented 2 years ago

I will update the README.md accordingly, thanks for pointing this out. You can easily upgrade to Sonarr V3 without losing data. See the instructions: https://sonarr.tv/#downloads-v3-linux-ubuntu

faulander commented 2 years ago

i am not updating a service which is running for years without a problem. Maybe i adapt excludarr to also work with V2, if i get it to run. Thanks for your help!

haijeploeg commented 2 years ago

That's also fine :). Keep in mind that Sonarr V2 is EOL so you may take a security risk depending on where it runs.

Most of the api calls and existing code should work fine with Sonarr V2 as well on the legacy /api endpoint. But not all data that is being used by excludarr is returned via that API endpoint. I think the best thing to do is to create a backup of your machine (or sonarr installation) and try to upgrade. I personally did not have any problems in upgrading Sonarr over the years and my library is still intact :). I'd be happy to help you in the future if you have any questions!