digitalec / deemon

Monitor specified artists for new releases
GNU General Public License v3.0
176 stars 15 forks source link

deezer.errors.PermissionException: PermissionException: playlist/1257036831 An active access token must be used to query information about the current user #55

Closed mathiasfoster closed 2 years ago

mathiasfoster commented 2 years ago
> rm .config/deemon/logs/deemon.log
# start with a blank slate of logs

> deemon -V
deemon 2.9.0-beta3 # same error with 2.8.2, upgrading didn't help

> deemon refresh
:: Starting database refresh
:: Fetching playlist track data for 12 playlist(s), please wait...  58%
Traceback (most recent call last):
  File "/home/mathias/.local/bin/deemon", line 8, in <module>
    sys.exit(main())
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/__main__.py", line 5, in main
    cli.run()
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke

    return __callback(*args, **kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cli.py", line 268, in refresh_command
    refresh.run()
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/refresh.py", line 220, in run
    api_result = self.get_release_data({'artists': monitored_artists, 'playlists': monitored_playlists})
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/refresh.py", line 302, in get_release_data
    api_result['playlists'] = list(
  File "/home/mathias/.local/lib/python3.8/site-packages/tqdm/std.py", line 1185, in __iter__
    for obj in iterable:
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
    yield fs.pop().result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/core/api.py", line 203, in get_playlist_tracks
    api_result = Deezer().api.get_playlist(query['id'])
  File "/home/mathias/.local/lib/python3.8/site-packages/deezer/api.py", line 153, in get_playlist
    return self.api_call(f'playlist/{str(playlist_id)}')
  File "/home/mathias/.local/lib/python3.8/site-packages/deezer/api.py", line 49, in api_call
    if result_json['error']['code'] == 200: raise PermissionException(f"PermissionException: {method} {result_json['error']['message'] if 'message' in result_json['error'] else ''}")
deezer.errors.PermissionException: PermissionException: playlist/1257036831 An active access token must be used to query information about the current user

> cd .config/deemon/logs && cat deemon.log
2022-02-02 13:06:36 [DEBUG] deemon.cli: deemon 2.9.0-beta3
2022-02-02 13:06:36 [DEBUG] deemon.cli: command: "refresh"
2022-02-02 13:06:36 [DEBUG] deemon.cli: Python 3.8.10
2022-02-02 13:06:36 [DEBUG] deemon.cli: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.29
2022-02-02 13:06:36 [DEBUG] deemon.cli: deemon appdata is located at /home/mathias/.config/deemon
2022-02-02 13:06:36 [DEBUG] deemon.core.config: Loading configuration, please wait...
2022-02-02 13:06:36 [DEBUG] deemon.core.config: Attempting to locate deemix's .arl file
2022-02-02 13:06:36 [DEBUG] deemon.core.config: Successfully loaded ARL
2022-02-02 13:06:36 [DEBUG] deemon.core.db: Database version 3.5.2
2022-02-02 13:06:36 [DEBUG] deemon.core.db: DATABASE UPGRADE IN PROGRESS!
2022-02-02 13:06:36 [DEBUG] deemon.core.config: Loaded config for profile 1 (default)
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > check_update: 1
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > debug_mode: True
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > release_channel: stable
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > query_limit: 5
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > rollback_view_limit: 10
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > prompt_duplicates: False
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > prompt_no_matches: True
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > new_releases/by_release_date: 1
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > new_releases/release_max_age: 90
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > global/bitrate: 128
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > global/alerts: False
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > global/record_type: all
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > global/download_path: Music
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > global/email:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > deemix/path:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > deemix/arl: ********
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > deemix/check_account_status: False
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > smtp_settings/server:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > smtp_settings/port: ********
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > smtp_settings/username:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > smtp_settings/password:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > smtp_settings/from_addr:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > plex/base_url:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > plex/token:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > plex/library:
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > experimental/experimental_api: True
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > experimental/allow_unofficial_releases: False
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > experimental/allow_compilations: False
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > experimental/allow_featured_in: False
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > profile_id: 1
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > tid: 159
2022-02-02 13:06:36 [DEBUG] deemon.core.config: > profile_name: default
2022-02-02 13:06:36 [INFO] deemon.cli: :: Starting database refresh
2022-02-02 13:06:37 [DEBUG] deemon.core.api: Deezer account type is "Free"
2022-02-02 13:06:37 [DEBUG] deemon.core.api: Using GW API, max_threads set to 50
2022-02-02 13:06:37 [DEBUG] deemon.cmd.refresh: DEBUG_MODE: FullRefresh
2022-02-02 13:06:37 [DEBUG] deemon.cmd.refresh: Standby, starting refresh...
2022-02-02 13:06:37 [DEBUG] deemon.cmd.refresh: Fetching playlist track data...
2022-02-02 13:06:37 [DEBUG] deemon.cmd.refresh: DEBUG_MODE: SpawningThreads 50

An error with upgrading the database? Or alternatively, a playlist issue?

I've had this error for about a week, first on 2.8.2 then continuing when I upgraded to 2.9.0-beta3.

mathiasfoster commented 2 years ago

This is what happens when trying deemon search.

> deemon search
# ... get to the point of selecting a track
:: [SELECT] Please choose an option or type 'exit': 1
{'id': 911221012, 'readable': True, 'title': 'Great Boleros Of Fire (Live 1977)', 'title_short': 'Great Boleros Of Fire', 'title_version': '(Live 1977)', 'isrc': 'GBSMU7724364', 'link': 'https://www.deezer.com/track/911221012', 'duration': 236, 'track_position': 1, 'disk_number': 1, 'rank': 206506, 'explicit_lyrics': False, 'explicit_content_lyrics': 2, 'explicit_content_cover': 2, 'preview': 'https://cdns-preview-9.dzcdn.net/stream/c-94c5d62820797dd86c541f3b164f993a-6.mp3', 'md5_image': '093ee6df448cab16637fefcaba7990ce', 'artist': {'id': 533311, 'name': 'Meatloaf', 'tracklist': 'https://api.deezer.com/artist/533311/top?limit=50', 'type': 'artist'}, 'type': 'track'}
Traceback (most recent call last):
  File "/home/mathias/.local/bin/deemon", line 8, in <module>
    sys.exit(main())
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/__main__.py", line 5, in main
    cli.run()
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cli.py", line 435, in search
    client.search_menu()
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 100, in search_menu
    artist_selected = self.artist_menu(self.search_results['query'], self.search_results['results'], quick_search)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 161, in artist_menu
    self.album_menu(results[response])
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 304, in album_menu
    self.track_menu(filtered_choices[selected_index])
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 361, in track_menu
    self.send_to_queue(selected_item)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 450, in send_to_queue
    if item['record_type'] in ['album', 'ep', 'single']:
KeyError: 'record_type'

> cat .config/deemon/logs/deemon.log
# ... previous logs elided
2022-02-02 13:08:56 [DEBUG] deemon.cli: deemon 2.9.0-beta3
2022-02-02 13:08:56 [DEBUG] deemon.cli: command: "search"
2022-02-02 13:08:56 [DEBUG] deemon.cli: Python 3.8.10
2022-02-02 13:08:56 [DEBUG] deemon.cli: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.29
2022-02-02 13:08:56 [DEBUG] deemon.cli: deemon appdata is located at /home/mathias/.config/deemon
2022-02-02 13:08:56 [DEBUG] deemon.core.config: Loading configuration, please wait...
2022-02-02 13:08:56 [DEBUG] deemon.core.config: Attempting to locate deemix's .arl file
2022-02-02 13:08:56 [DEBUG] deemon.core.config: Successfully loaded ARL
2022-02-02 13:08:56 [DEBUG] deemon.core.db: Database version 3.5.2
2022-02-02 13:08:56 [DEBUG] deemon.core.db: DATABASE UPGRADE IN PROGRESS!
2022-02-02 13:08:56 [DEBUG] deemon.core.config: Loaded config for profile 1 (default)
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > check_update: 1
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > debug_mode: True
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > release_channel: stable
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > query_limit: 5
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > rollback_view_limit: 10
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > prompt_duplicates: False
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > prompt_no_matches: True
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > new_releases/by_release_date: 1
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > new_releases/release_max_age: 90
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > global/bitrate: 128
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > global/alerts: False
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > global/record_type: all
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > global/download_path: Music
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > global/email:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > deemix/path:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > deemix/arl: ********
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > deemix/check_account_status: False
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > smtp_settings/server:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > smtp_settings/port: ********
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > smtp_settings/username:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > smtp_settings/password:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > smtp_settings/from_addr:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > plex/base_url:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > plex/token:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > plex/library:
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > experimental/experimental_api: True
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > experimental/allow_unofficial_releases: False
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > experimental/allow_compilations: False
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > experimental/allow_featured_in: False
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > profile_id: 1
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > tid: 159
2022-02-02 13:08:56 [DEBUG] deemon.core.config: > profile_name: default
2022-02-02 13:08:57 [DEBUG] deemon.core.api: Deezer account type is "Free"
2022-02-02 13:08:57 [DEBUG] deemon.core.api: Using GW API, max_threads set to 50
2022-02-02 13:09:03 [DEBUG] deemon.core.api: DEBUG_MODE: RefreshArtist Meatloaf
mathiasfoster commented 2 years ago

After deleting deemon.db and starting again:

# Export Artist IDs to CSV
> deemon show artists -cHf id -e artists.csv

# Delete database
> rm ~/.config/deemon/deemon.db

# Import artists setting time machine date to last refresh
> deemon monitor -I artists.csv -T 2022-01-28

> deemon search
# get to the point of adding a track
:: [SELECT] Please choose an option or type 'exit': 1
{'id': 1632297152, 'readable': True, 'title': 'High', 'title_short': 'High', 'title_version': '', 'isrc': 'USQX92105208', 'link': 'https://www.deezer.com/track/1632297152', 'duration': 175, 'track_position': 1, 'disk_number': 1, 'rank': 912726, 'explicit_lyrics': True, 'explicit_content_lyrics': 1, 'explicit_content_cover': 2, 'preview': 'https://cdns-preview-4.dzcdn.net/stream/c-412eb6fad6d3395f29e05787e7aa3d9e-3.mp3', 'md5_image': 'bad3a7e5a75316205db68a254c57c0ab', 'artist': {'id': 4104927, 'name': 'The Chainsmokers', 'tracklist': 'https://api.deezer.com/artist/4104927/top?limit=50', 'type': 'artist'}, 'type': 'track'}
Traceback (most recent call last):
  File "/home/mathias/.local/bin/deemon", line 8, in <module>
    sys.exit(main())
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/__main__.py", line 5, in main
    cli.run()
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mathias/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cli.py", line 435, in search
    client.search_menu()
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 100, in search_menu
    artist_selected = self.artist_menu(self.search_results['query'], self.search_results['results'], quick_search)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 161, in artist_menu
    self.album_menu(results[response])
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 304, in album_menu
    self.track_menu(filtered_choices[selected_index])
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 361, in track_menu
    self.send_to_queue(selected_item)
  File "/home/mathias/.local/lib/python3.8/site-packages/deemon/cmd/search.py", line 450, in send_to_queue
    if item['record_type'] in ['album', 'ep', 'single']:
KeyError: 'record_type'

Odd error!

digitalec commented 2 years ago

Looks like two different bugs here. The playlist issue seems to be caused by a private playlist perhaps? Do you know which one?

The second bug with search is probably related to the conversion to the new API. I’ll take a look further into both.

digitalec commented 2 years ago

Bug 1

Ok, I looked into this and the first issue deezer.errors.PermissionException is caused because the playlist is private and you don't have permission to see it (at least with the ARL you're using). I get the same error when I try to monitor the playlist in question (1257036831). Chances are you started monitoring it and then it was made private or it's an issue with the ARL not matching your account. Can you see the playlist itself?

I just patched this in commit e68623d. Now, instead of a crash, you'll simply see the message Playlist ID 1257036831 is private when trying to monitor a private playlist or Playlist ID 1257036831 was not found when trying to monitor a playlist ID that doesn't exist. There's no error checking (yet) for already monitored playlists so you'll have to remove it via deemon monitor -R -p <playlist_url>.


Bug 2 & 3

I found two different bugs in deemon search while investigating the bug you reported. The first affects v2.8.2 which will crash with a TypeError exception when selecting a specific track. The second bug affects v2.9.0-beta3 which will cause the KeyError you reported when selecting a track.

I'm pushing 2.8.3 and 2.9.0-beta4 in the next few minutes to address these bugs. Feel free to reopen/comment if needed.