glomatico / spotify-web-downloader

A Python CLI app for downloading songs/music videos/albums/playlists directly from Spotify.
378 stars 43 forks source link

[bug] Empty config.json + in config path = error #54

Open Velocet opened 1 month ago

Velocet commented 1 month ago

When run from inside the config dir with an empty config.json the tool errors out.

$> $env:USERPROFILE\.spotify-web-downloader>spotify-web-downloader "https://open.spotify.com/track/4PTG3Z6ehGkBFwjybzWkR8"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Program Files\Python\Scripts\spotify-web-downloader.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\site-packages\click\core.py", line 1077, in main
    with self.make_context(prog_name, args, **extra) as ctx:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\site-packages\click\core.py", line 943, in make_context
    self.parse_args(ctx, args)
  File "C:\Program Files\Python\Lib\site-packages\click\core.py", line 1408, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\site-packages\click\core.py", line 2400, in handle_parse_result
    value = self.process_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\site-packages\click\core.py", line 2362, in process_value
    value = self.callback(ctx, self, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\site-packages\spotify_web_downloader\cli.py", line 54, in load_config_file
    config_file = dict(json.loads(ctx.params["config_path"].read_text()))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)