acgonzales / pydeezer

A package to search and download musics on Deezer.
The Unlicense
53 stars 14 forks source link

Compatibilty with deezer-py package #24

Open JOJ0 opened 3 years ago

JOJ0 commented 3 years ago

Seems pydeezer is not compatible with the latest versions of package deezer-py:

(pydeezer) jojo@gin ~/git $ pydeezer download
Traceback (most recent call last):
  File "/Users/jojo/.venvs/pydeezer/bin/pydeezer", line 5, in <module>
    from pydeezer.cli import cli
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/pydeezer/__init__.py", line 5, in <module>
    from .Deezer import Deezer
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/pydeezer/Deezer.py", line 6, in <module>
    from deezer.gw import APIError as GWAPIError
ImportError: cannot import name 'APIError' from 'deezer.gw' (/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/deezer/gw.py)

I tried several versions of deezer-py. It at least did not fail at the import already with 0.0.15:

(pydeezer) jojo@gin ~/git/pydeezer (master) $ pip install deezer-py==0.0.15
Requirement already satisfied: deezer-py==0.0.15 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (0.0.15)
Requirement already satisfied: eventlet in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from deezer-py==0.0.15) (0.31.1)
Requirement already satisfied: requests in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from deezer-py==0.0.15) (2.26.0)
Requirement already satisfied: greenlet>=0.3 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from eventlet->deezer-py==0.0.15) (1.1.1)
Requirement already satisfied: dnspython<2.0.0,>=1.15.0 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from eventlet->deezer-py==0.0.15) (1.16.0)
Requirement already satisfied: six>=1.10.0 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from eventlet->deezer-py==0.0.15) (1.16.0)
Requirement already satisfied: certifi>=2017.4.17 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from requests->deezer-py==0.0.15) (2021.5.30)
Requirement already satisfied: idna<4,>=2.5 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from requests->deezer-py==0.0.15) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from requests->deezer-py==0.0.15) (1.26.6)
Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages (from requests->deezer-py==0.0.15) (2.0.4)
(pydeezer) jojo@gin ~/git/pydeezer (master) $

(pydeezer) jojo@gin ~/git/pydeezer (master) $ pydeezer --help
Usage: pydeezer [OPTIONS] COMMAND [ARGS]...

  PyDeezer CLI

Options:
  --help  Show this message and exit.

Commands:
  download  Download tracks
(pydeezer) jojo@gin ~/git/pydeezer (master) $ pydeezer download --help
Usage: pydeezer download [OPTIONS]

  Download tracks

Options:
  -a, --arl TEXT                  Used to be able to login to Deezer. Check
                                  the docs on how to get one.
  --media-type [Track|Album|Playlist|Artist]
                                  Sets the media type and how it searches the
                                  api.
  -d, --download-dir DIRECTORY    Sets the directory on where the tracks are
                                  to be saved.
  -q, --quality [MP3_128|MP3_256|MP3_320|FLAC]
                                  Sets the quality of the tracks. if the
                                  provided quality is not supported, the
                                  default quality of the track will be used.
  --help                          Show this message and exit.

But then I get the following errors after putting in the ARL:

 (pydeezer) jojo@gin ~/git/pydeezer (master) $ pydeezer download
? Please input your ARL.  xxxsecretxxxsecretxxx
Traceback (most recent call last):
  File "/Users/jojo/.venvs/pydeezer/bin/pydeezer", line 8, in <module>
    sys.exit(cli())
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/pydeezer/cli.py", line 43, in download
    user = prompt({
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/PyInquirer/prompt.py", line 69, in prompt
    answer = run_application(
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/shortcuts.py", line 625, in run_application
    result = cli.run()
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/interface.py", line 415, in run
    self.eventloop.run(self.input, self.create_eventloop_callbacks())
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/eventloop/posix.py", line 164, in run
    t()
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/eventloop/posix.py", line 83, in read_from_stdin
    inputstream.feed(data)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/terminal/vt100_input.py", line 398, in feed
    self._input_parser.send(c)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/terminal/vt100_input.py", line 307, in _input_parser_generator
    self._call_handler(match, prefix)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/terminal/vt100_input.py", line 340, in _call_handler
    self.feed_key_callback(KeyPress(key, insert_text))
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/interface.py", line 1043, in feed_key
    cli.input_processor.process_keys()
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/key_binding/input_processor.py", line 219, in process_keys
    self._process_coroutine.send(key_press)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/key_binding/input_processor.py", line 176, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/key_binding/input_processor.py", line 247, in _call_handler
    handler.call(event)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/key_binding/registry.py", line 61, in call
    return self.handler(event)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/key_binding/bindings/basic.py", line 167, in _
    buff.accept_action.validate_and_handle(event.cli, buff)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/buffer.py", line 82, in validate_and_handle
    if buffer.validate():
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/prompt_toolkit/buffer.py", line 1104, in validate
    self.validator.validate(self.document)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/PyInquirer/prompts/input.py", line 26, in validate
    verdict = validate_prompt(document.text)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/pydeezer/cli.py", line 38, in validate_arl
    deezer.login_via_arl(arl)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/pydeezer/Deezer.py", line 52, in login_via_arl
    super().login_via_arl(arl, child=child)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/deezer/__init__.py", line 84, in login_via_arl
    user_data = self.gw.get_user_data()
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/deezer/gw.py", line 86, in get_user_data
    return self.api_call('deezer.getUserData')
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/deezer/gw.py", line 75, in api_call
    eventlet.sleep(2)
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/eventlet/greenthread.py", line 36, in sleep
    hub.switch()
  File "/Users/jojo/.venvs/pydeezer/lib/python3.9/site-packages/eventlet/hubs/hub.py", line 313, in switch
    return self.greenlet.switch()
eventlet.hubs.IOClosed: [Errno 57] Operation on closed file

Giving ARL on CLI using the -a option results in the same error.