Skip to content
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

"TypeError: byte indices must be integers or slices, not str" error when url in ./.excludarr.yml ends with a / #82

Open
NeilSCGH opened this issue Jan 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@NeilSCGH
Copy link

Hi, I solved my problem when writing this, but I think a little patch would have saved me from debugging all of this.
My problem was that in ./.excludarr.yml, I've writed the url of radarr with an / at the end...

Here is my original issue :

Hi, when I try to run excludarr in docker with the following command docker run -it --rm --env-file /volume1/docker/excludarr/excludarr_docker.env haijeploeg/excludarr:latest --debug radarr exclude -a delete

I have the following error TypeError: byte indices must be integers or slices, not str, complete logs at the end of this post.

When I try the same command but without docker (as root afteer installing excludarr with pip : excludarr --debug radarr exclude -a delete), I have the same error but I see that the movie variable contains :
b'<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>'
(I've added a print to print the entire value of the variable "movie")

The I tried to use pipredream instead of my radarr server to see what request excludarr is sending to radarr, and I have this request :

headers :
	accept: */*
	accept-encoding:gzip, deflate
	host:xxxxxxxxxxxxxx.m.pipedream.net
	user-agent:python-requests/2.28.2
	x-api-key:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
path:/api/v3/movie
url:https://xxxxxxxxxxxxxx.m.pipedream.net/api/v3/movie

So I tried to make the same request to my radarr with postman, and I have this result after 10 seconds :

[
    {
        "title": "Batman v Superman : L'Aube de la Justice",
        "originalTitle": "Batman v Superman: Dawn of Justice",
        "originalLanguage": {
            "id": 1,
            "name": "English"
        },
        "alternateTitles": [
            {
                "sourceType": "tmdb",
                "movieMetadataId": 1,
                "title": "Batman versus Superman: Dawn of Justice",
                "sourceId": 0,
                "votes": 0,
    ...

Do you know why I have this error ? It seems that the requests are not exactly the same between excludarr and postman, because I don't have the same result. An other difference is that excludar make the request from the same machine, when postman is from my computer.
I'm running everything (except postman) on a synology nas. Commands are via ssh, radarr is in a docker container.

Note : when I try the same command but with sonarr (also in a container), it works well and I get the list of tv shows to delete, no errors.

./.excludarr.yml :

general:
  fast_search: true
  locale: fr_FR
  providers:
    - Netflix
    - Amazon Prime Video

tmdb:
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

radarr:
  url: http://192.168.0.41:7878/
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  verify_ssl: false

sonarr:
  url: http://192.168.0.41:8989
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  verify_ssl: false

excludarr_docker.env file for docker :

GENERAL_FAST_SEARCH=true
GENERAL_LOCALE=fr_FR
GENERAL_PROVIDERS=netflix, amazon prime video
RADARR_URL=http://192.168.0.41:7878/
RADARR_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
RADARR_VERIFY_SSL=false
SONARR_URL=http://192.168.0.41:8989
SONARR_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SONARR_VERIFY_SSL=false

Complete log with docker :

ash-4.4# docker run -it --rm --env-file /volume1/docker/excludarr/excludarr_docker.env haijeploeg/excludarr:latest --debug radarr exclude -a delete
2023-01-29 16:39:27] - Starting Excludarr v1.0.7
[2023-01-29 16:39:27] - Got radarr as subcommand
[2023-01-29 16:39:27] - Reading configuration file
[2023-01-29 16:39:27] - Determining which configfile to use
[2023-01-29 16:39:28] - Configfile to use: /etc/excludarr/excludarr.yml
[2023-01-29 16:39:28] - Reading configfile: /etc/excludarr/excludarr.yml
[2023-01-29 16:39:28] - Read the following configuration: {'general': {'fast_search': True, 'locale': 'fr_FR', 'providers': ['netflix', 'amazon prime video']}, 'radarr': {'url': 'http://192.168.0.41:7878/', 'api_key': '<REDACTED>', 'verify_ssl': False, 'exclude': ['']}, 'sonarr': {'url': 'http://192.168.0.41:8989', 'api_key': '<REDACTED>', 'verify_ssl': False, 'exclude': ['']}}
[2023-01-29 16:39:28] - Got exclude as subcommand
[2023-01-29 16:39:28] - Got CLI values for -p, --provider option:
[2023-01-29 16:39:28] - Got CLI values for -l, --locale option: None
[2023-01-29 16:39:28] - Got CLI values for -a, --action option: delete
[2023-01-29 16:39:28] - Got CLI values for -d, --delete option: False
[2023-01-29 16:39:28] - Got CLI values for -e, --exclusion option: False
[2023-01-29 16:39:28] - Got CLI values for -y, --yes option: False
[2023-01-29 16:39:28] - Got CLI values for --progress option: False
[2023-01-29 16:39:28] - Initializing PyRadarr
[2023-01-29 16:39:28] - Initializing JustWatch API with locale: fr_FR
[2023-01-29 16:39:29] - Getting all the movies from Radarr
[2023-01-29 16:39:37] - Got the following providers: Netflix, Amazon Prime Video
Traceback (most recent call last):
  File "/usr/local/bin/excludarr", line 33, in <module>
    sys.exit(load_entry_point('excludarr==1.0.7', 'console_scripts', 'excludarr')())
  File "/usr/local/lib/python3.10/site-packages/excludarr-1.0.7-py3.10.egg/excludarr/main.py", line 68, in cli
  File "/usr/local/lib/python3.10/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.10/site-packages/excludarr-1.0.7-py3.10.egg/excludarr/commands/radarr.py", line 84, in exclude
  File "/usr/local/lib/python3.10/site-packages/excludarr-1.0.7-py3.10.egg/excludarr/core/radarr_actions.py", line 98, in get_movies_to_exclude
TypeError: byte indices must be integers or slices, not str

Complete log without docker:

ash-4.4# excludarr --debug radarr exclude -a delete
[2023-01-29 17:57:38] - Starting Excludarr v1.0.7
[2023-01-29 17:57:38] - Got radarr as subcommand
[2023-01-29 17:57:38] - Reading configuration file
[2023-01-29 17:57:38] - Determining which configfile to use
[2023-01-29 17:57:38] - Configfile to use: ./.excludarr.yml
[2023-01-29 17:57:38] - Reading configfile: ./.excludarr.yml
[2023-01-29 17:57:38] - Read the following configuration: {'general': {'fast_search': True, 'locale': 'fr_FR', 'providers': ['Netflix', 'Amazon Prime Video']}, 'tmdb': {'api_key': '<REDACTED>'}, 'radarr': {'url': 'http://192.168.0.41:7878/', 'api_key': '<REDACTED>', 'verify_ssl': False}, 'sonarr': {'url': 'http://192.168.0.41:8989', 'api_key': '<REDACTED>', 'verify_ssl': False}}
[2023-01-29 17:57:38] - Got exclude as subcommand
[2023-01-29 17:57:38] - Got CLI values for -p, --provider option:
[2023-01-29 17:57:38] - Got CLI values for -l, --locale option: None
[2023-01-29 17:57:38] - Got CLI values for -a, --action option: delete
[2023-01-29 17:57:38] - Got CLI values for -d, --delete option: False
[2023-01-29 17:57:38] - Got CLI values for -e, --exclusion option: False
[2023-01-29 17:57:38] - Got CLI values for -y, --yes option: False
[2023-01-29 17:57:38] - Got CLI values for --progress option: False
[2023-01-29 17:57:38] - Initializing PyRadarr
[2023-01-29 17:57:38] - Initializing JustWatch API with locale: fr_FR
[2023-01-29 17:57:39] - Getting all the movies from Radarr
[2023-01-29 17:57:40] - Got the following providers: Netflix, Amazon Prime Video
movie value : b'<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/lib/python3.8/site-packages/excludarr/commands/radarr.py:84 in exclude                      │
│                                                                                                  │
│    81 │   radarr = RadarrActions(config.radarr_url, config.radarr_api_key, locale)               │
│    82 │                                                                                          │
│    83 │   # Get the movies to exclude and exclude the movies that are in the exclude list        │
│ ❱  84 │   movies_to_exclude = radarr.get_movies_to_exclude(                                      │
│    85 │   │   providers, config.fast_search, disable_progress                                    │
│    86 │   )                                                                                      │
│    87                                                                                            │
│                                                                                                  │
│ ╭───────────────────────────────────────── locals ──────────────────────────────────────────╮    │
│ │           action = <Action.delete: 'delete'>                                              │    │
│ │     delete_files = False                                                                  │    │
│ │ disable_progress = True                                                                   │    │
│ │        exclusion = False                                                                  │    │
│ │           locale = 'fr_FR'                                                                │    │
│ │         progress = False                                                                  │    │
│ │        providers = ['Netflix', 'Amazon Prime Video']                                      │    │
│ │           radarr = <excludarr.core.radarr_actions.RadarrActions object at 0x7fde6b9032e0> │    │
│ │              yes = False                                                                  │    │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────╯    │
│                                                                                                  │
│ /usr/lib/python3.8/site-packages/excludarr/core/radarr_actions.py:100 in get_movies_to_exclude   │
│                                                                                                  │
│    97 │   │   │   for movie in progress.track(radarr_movies):                                    │
│    98 │   │   │   │   # Set the minimal base variables                                           │
│    99 │   │   │   │   print(movie)                                                               │
│ ❱ 100 │   │   │   │   radarr_id = movie["id"]                                                    │
│   101 │   │   │   │   title = movie["title"]                                                     │
│   102 │   │   │   │   tmdb_id = movie["tmdbId"]                                                  │
│   103 │   │   │   │   filesize = movie["sizeOnDisk"]                                             │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ disable_progress = True                                                                      │ │
│ │   exclude_movies = {}                                                                        │ │
│ │             fast = True                                                                      │ │
│ │     jw_providers = {                                                                         │ │
│ │                    │   8: {'short_name': 'nfx', 'clear_name': 'Netflix'},                    │ │
│ │                    │   119: {'short_name': 'prv', 'clear_name': 'Amazon Prime Video'}        │ │
│ │                    }                                                                         │ │
│ │            movie = b'<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta       │ │
│ │                    name="viewport'+48                                                        │ │
│ │         progress = <rich.progress.Progress object at 0x7fde6b8eaee0>                         │ │
│ │        providers = ['Netflix', 'Amazon Prime Video']                                         │ │
│ │    radarr_movies = <Response [200]>                                                          │ │
│ │ raw_jw_providers = [                                                                         │ │
│ │                    │   {                                                                     │ │
│ │                    │   │   'id': 8,                                                          │ │
│ │                    │   │   'technical_name': 'netflix',                                      │ │
│ │                    │   │   'short_name': 'nfx',                                              │ │
│ │                    │   │   'clear_name': 'Netflix',                                          │ │
│ │                    │   │   'display_priority': 0,                                            │ │
│ │                    │   │   'priority': 0,                                                    │ │
│ │                    │   │   'monetization_types': ['flatrate'],                               │ │
│ │                    │   │   'icon_url': '/icon/207360008/{profile}',                          │ │
│ │                    │   │   'icon_blur_hash': 'KVBJXFjt1^jto1a|A;a|,Z',                       │ │
│ │                    │   │   'slug': 'netflix',                                                │ │
│ │                    │   │   ... +3                                                            │ │
│ │                    │   },                                                                    │ │
│ │                    │   {                                                                     │ │
│ │                    │   │   'id': 119,                                                        │ │
│ │                    │   │   'technical_name': 'amazonprimevideo',                             │ │
│ │                    │   │   'short_name': 'prv',                                              │ │
│ │                    │   │   'clear_name': 'Amazon Prime Video',                               │ │
│ │                    │   │   'display_priority': 1,                                            │ │
│ │                    │   │   'priority': 0,                                                    │ │
│ │                    │   │   'monetization_types': ['flatrate'],                               │ │
│ │                    │   │   'icon_url': '/icon/52449861/{profile}',                           │ │
│ │                    │   │   'icon_blur_hash': 'KMQAQ@%M~Ux]WCjF~qj[IU',                       │ │
│ │                    │   │   'slug': 'amazon-prime-video',                                     │ │
│ │                    │   │   ... +3                                                            │ │
│ │                    │   },                                                                    │ │
..... (only a list of providers here)
│ │                    │   {                                                                     │ │
│ │                    │   │   'id': 147,                                                        │ │
│ │                    │   │   'technical_name': 'sixplay',                                      │ │
│ │                    │   │   'short_name': 'sxp',                                              │ │
│ │                    │   │   'clear_name': 'Sixplay',                                          │ │
│ │                    │   │   'display_priority': 10,                                           │ │
│ │                    │   │   'priority': 0,                                                    │ │
│ │                    │   │   'monetization_types': ['ads'],                                    │ │
│ │                    │   │   'icon_url': '/icon/5870395/{profile}',                            │ │
│ │                    │   │   'icon_blur_hash': 'KTA^Rmt6Z~t7j[ay4TWAt7',                       │ │
│ │                    │   │   'slug': 'sixplay',                                                │ │
│ │                    │   │   ... +3                                                            │ │
│ │                    │   },                                                                    │ │
│ │                    │   ... +80                                                               │ │
│ │                    ]                                                                         │ │
│ │             self = <excludarr.core.radarr_actions.RadarrActions object at 0x7fde6b9032e0>    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: byte indices must be integers or slices, not str
@NeilSCGH NeilSCGH added the bug Something isn't working label Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant