Skip to content

[BUG] TypeError: string indices must be integers, not 'str' #307

@AlexanderShad

Description

@AlexanderShad

Describe the bug
It crashes when I try to add it to favorites.

To Reproduce
Steps to reproduce the behavior:

  1. Press 'Shift + O'
  2. Select 'Radio Station 64'
  3. Press 'Shift + 8' (to press *, laptop)
  4. See error:

~ ❯ pyradio
Reading playlist...
Traceback (most recent call last):
File "/usr/bin/pyradio", line 9, in
sys.exit(shell())
^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/main.py", line 1184, in shell
curses.wrapper(pyradio.setup)
File "/usr/lib64/python3.12/curses/init.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/radio.py", line 1341, in setup
self.run()
File "/usr/lib/python3/site-packages/pyradio/radio.py", line 2260, in run
ret = self.keypress(c) # Handle shortcut
^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/radio.py", line 9771, in keypress
ret, msg = self._cnf.add_to_favorites(self.stations[self.selection])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/config.py", line 208, in add_to_favorites
return self.favorites.add(an_item)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/config.py", line 4403, in add
ret = self._write_csv(items)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/config.py", line 4423, in _write_csv
ret = csv_out.write(items=items)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/common.py", line 868, in write
writter.writerow(self._format_playlist_row(a_station))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/site-packages/pyradio/common.py", line 834, in _format_playlist_row
this_row[Station.icon] = this_row[Station.icon]['image']
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: string indices must be integers, not 'str'

The error only occurs on this station.

Expected behavior
Add to favorites

System (please complete the following information):

  • OS: ALT Linux (ALT Sisyphus)
  • Python version: 3.12.11
  • PyRadio Version: 0.9.3.11.19
  • Player used: mpv

Additional context
the station continues playing after an error

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions