max menu items = 9999; this isn't really supposed to give you the entire database

This commit is contained in:
Greg Gauthier 2021-03-16 08:13:48 +00:00
parent 446b80da2e
commit feb5277d7b
4 changed files with 20 additions and 12 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
__pycache__/ __pycache__/
.idea/ .idea/
*.lock *.lock
*.iml

View File

@ -15,3 +15,7 @@ def player():
def options(): def options():
return config.get('DEFAULT', 'player.options') return config.get('DEFAULT', 'player.options')
def maxitems():
return int(config.get('DEFAULT', 'menu_items.max'))

View File

@ -1,7 +1,7 @@
from python_console_menu import AbstractMenu, MenuItem from python_console_menu import AbstractMenu, MenuItem
import subprocess import subprocess
from config import player, options from config import player, options, maxitems
class RadioMenu(AbstractMenu): class RadioMenu(AbstractMenu):
@ -11,6 +11,7 @@ class RadioMenu(AbstractMenu):
station_list = [] station_list = []
for i in range(len(station_list)): for i in range(len(station_list)):
if i < maxitems(): # The last item is the exit option, so not "<=".
self.add_menu_item( self.add_menu_item(
MenuItem( MenuItem(
i, i,
@ -21,6 +22,8 @@ class RadioMenu(AbstractMenu):
lambda url=station_list[i]["url"]: subprocess.run([player(), options(), url]) lambda url=station_list[i]["url"]: subprocess.run([player(), options(), url])
) )
) )
else:
break
def initialise(self): def initialise(self):
self.add_menu_item(MenuItem(9999, "Exit menu").set_as_exit_option()) self.add_menu_item(MenuItem(maxitems(), "Exit menu").set_as_exit_option())

View File

@ -2,4 +2,4 @@
radio_browser.api=all.api.radio-browser.info radio_browser.api=all.api.radio-browser.info
player.command=mpv player.command=mpv
player.options=--no-video player.options=--no-video
menu_items.max=9999