[GH-ISSUE #8] KeyError when album is not specified #7

Closed
opened 2026-05-22 22:02:30 +01:00 by JakeStanger · 5 comments
Owner

Originally created by @EgZvor on GitHub (Oct 5, 2018).
Original GitHub issue: https://github.com/JakeStanger/Rofi_MPD/issues/8

Traceback (most recent call last):
  File "main.py", line 270, in <module>
    select_artist(selection_list)
  File "main.py", line 217, in select_artist
    select(title or 'All Artists', [*data])
  File "main.py", line 188, in select
    select_album(selection_list, selected_data)
  File "main.py", line 223, in select_album
    select(artist or 'All Albums', data, full_album=full_album)
  File "main.py", line 191, in select
    select_track(selection_list, selected_data['artist'], selected_data['album'])
  File "main.py", line 231, in select_track
    data = sorted([*data],
  File "main.py", line 229, in <lambda>
    and (x['data']['album'] == album if album else True), data)
KeyError: 'album'
Originally created by @EgZvor on GitHub (Oct 5, 2018). Original GitHub issue: https://github.com/JakeStanger/Rofi_MPD/issues/8 ``` Traceback (most recent call last): File "main.py", line 270, in <module> select_artist(selection_list) File "main.py", line 217, in select_artist select(title or 'All Artists', [*data]) File "main.py", line 188, in select select_album(selection_list, selected_data) File "main.py", line 223, in select_album select(artist or 'All Albums', data, full_album=full_album) File "main.py", line 191, in select select_track(selection_list, selected_data['artist'], selected_data['album']) File "main.py", line 231, in select_track data = sorted([*data], File "main.py", line 229, in <lambda> and (x['data']['album'] == album if album else True), data) KeyError: 'album' ```
JakeStanger 2026-05-22 22:02:30 +01:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@JakeStanger commented on GitHub (Oct 5, 2018):

Hi, could you give me the data causing this to fail please? I'm struggling to see why this would happen from just the code/error.

<!-- gh-comment-id:427500229 --> @JakeStanger commented on GitHub (Oct 5, 2018): Hi, could you give me the data causing this to fail please? I'm struggling to see why this would happen from just the code/error.
Author
Owner

@EgZvor commented on GitHub (Oct 6, 2018):

➜ ~/Music id3 Wallace\ Collection\ -\ Daydream.mp3 
File: Wallace Collection - Daydream.mp3
Metadata: ID3v2.3
Title: Daydream
Artist: Wallace Collection
<!-- gh-comment-id:427589712 --> @EgZvor commented on GitHub (Oct 6, 2018): ``` ➜ ~/Music id3 Wallace\ Collection\ -\ Daydream.mp3 File: Wallace Collection - Daydream.mp3 Metadata: ID3v2.3 Title: Daydream Artist: Wallace Collection ```
Author
Owner

@EgZvor commented on GitHub (Oct 6, 2018):

You can delete tags with id3 --delete <filename>

<!-- gh-comment-id:427590998 --> @EgZvor commented on GitHub (Oct 6, 2018): You can delete tags with `id3 --delete <filename>`
Author
Owner

@EgZvor commented on GitHub (Oct 6, 2018):

I think it's because of this.

            # Handle songs with missing album tag
            if 'album' in song:
                album = song['album']
            else:
                album = "[Unknown Album]"

[Unknown Album] is then used as a value, an the check if album doesn't apply.

<!-- gh-comment-id:427591881 --> @EgZvor commented on GitHub (Oct 6, 2018): I think it's because of this. ``` # Handle songs with missing album tag if 'album' in song: album = song['album'] else: album = "[Unknown Album]" ``` `[Unknown Album]` is then used as a value, an the check `if album` doesn't apply.
Author
Owner

@JakeStanger commented on GitHub (Oct 7, 2018):

Yep, it was exactly that! It should be fixed now.

<!-- gh-comment-id:427675672 --> @JakeStanger commented on GitHub (Oct 7, 2018): Yep, it was exactly that! It should be fixed now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/Rofi_MPD#7
No description provided.