mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
Merge pull request #31 from iMithrellas/feature-menu-order
feat: add menu order feature
This commit is contained in:
@@ -37,6 +37,7 @@ class Config(object):
|
||||
}
|
||||
default_config = {
|
||||
"auto_next": "False",
|
||||
"menu_order": "",
|
||||
"auto_select": "True",
|
||||
"cache_requests": "true",
|
||||
"check_for_updates": "True",
|
||||
@@ -163,6 +164,7 @@ class Config(object):
|
||||
self.server = self.configparser.get("stream", "server")
|
||||
self.skip = self.configparser.getboolean("stream", "skip")
|
||||
self.sort_by = self.configparser.get("anilist", "sort_by")
|
||||
self.menu_order = self.configparser.get("general", "menu_order")
|
||||
self.sub_lang = self.configparser.get("general", "sub_lang")
|
||||
self.translation_type = self.configparser.get("stream", "translation_type")
|
||||
self.use_fzf = self.configparser.getboolean("general", "use_fzf")
|
||||
@@ -358,6 +360,13 @@ image_previews = {self.image_previews}
|
||||
# used by the ```fastanime downloads``` command
|
||||
ffmpegthumbnailer_seek_time = {self.ffmpegthumbnailer_seek_time}
|
||||
|
||||
# specify the order of menu items in a comma-separated list.
|
||||
# only include the base names of menu options (e.g., "Trending", "Recent").
|
||||
# default value is 'Trending,Recent,Watching,Paused,Dropped,Planned,Completed,Rewatching,Recently Updated Anime,Search,Watch History,Random Anime,Most Popular Anime,Most Favourite Anime,Most Scored Anime,Upcoming Anime,Edit Config,Exit'
|
||||
# leave blank to use the default menu order.
|
||||
# you can also omit some options by not including them in the list
|
||||
menu_order = {self.menu_order}
|
||||
|
||||
# whether to use fzf as the interface for the anilist command and others. [True/False]
|
||||
use_fzf = {self.use_fzf}
|
||||
|
||||
|
||||
@@ -1715,6 +1715,18 @@ def fastanime_main_menu(
|
||||
f"{'📝 ' if icons else ''}Edit Config": _edit_config,
|
||||
f"{'❌ ' if icons else ''}Exit": exit_app,
|
||||
}
|
||||
|
||||
# Load main menu order if set in config file
|
||||
if config.menu_order:
|
||||
menu_order_list = config.menu_order.split(",")
|
||||
lookup = {key.split(" ", 1)[-1]: key for key in options}
|
||||
ordered_dict = {
|
||||
lookup[key]: options[lookup[key]]
|
||||
for key in menu_order_list
|
||||
if key in lookup
|
||||
}
|
||||
options = ordered_dict
|
||||
|
||||
# prompt user to select an action
|
||||
choices = list(options.keys())
|
||||
if config.use_fzf:
|
||||
|
||||
Reference in New Issue
Block a user