add: windows support

This commit is contained in:
starnakin 2023-05-20 19:04:18 +02:00
parent e14bb51127
commit 7a92e2c65f
2 changed files with 27 additions and 12 deletions

37
menu.py
View File

@ -1,12 +1,31 @@
from simple_term_menu import TerminalMenu from simple_term_menu import TerminalMenu
import dumb_menu
from database import Database from database import Database
from scrapper import get_files, get_uri from scrapper import get_files, get_uri
from utils import get_url, get from utils import get_url, get
import platform
uri = "" uri = ""
preview_site = {} preview_site = {}
preview_database = "" preview_database = ""
def get_user_choice_by_menu(options: list, title = None, preview_function=None, preview_size: float = 0.3, show_search_hint: bool = False, skip_empty_entries = False):
try:
None + 1;
terminal_menu = TerminalMenu(options,
preview_command=preview_function,
title=title,
show_search_hint=show_search_hint,
preview_size=preview_size,
skip_empty_entries=skip_empty_entries);
response = terminal_menu.show();
except:
response = dumb_menu.get_menu_choice(options);
return (response);
def add_site(database: Database) -> dict: def add_site(database: Database) -> dict:
print("add a site:") print("add a site:")
site = {} site = {}
@ -33,12 +52,11 @@ def files(site, path):
uri = path uri = path
preview_site = site preview_site = site
files = get_files(site, path) files = get_files(site, path)
terminal_menu = TerminalMenu(files, choose = get_user_choice_by_menu(files,
preview_command=files_preview, preview_command=files_preview,
preview_size=0.3, preview_size=0.3,
show_search_hint=True, show_search_hint=True,
title=f"Index of {path}") title=f"Index of {path}")
choose = terminal_menu.show()
if (choose == None): if (choose == None):
return (None) return (None)
return (files[choose]) return (files[choose])
@ -59,36 +77,31 @@ def site_deleter(sites, database: Database):
global preview_database global preview_database
preview_database = database preview_database = database
terminal_menu = TerminalMenu(sites, choose = get_user_choice_by_menu(sites,
show_search_hint=True, show_search_hint=True,
preview_title="delete", preview_title="delete",
preview_command=config_preview) preview_command=config_preview)
choose = terminal_menu.show()
return (choose) return (choose)
def param_editor(lst: list): def param_editor(lst: list):
terminal_menu = TerminalMenu(lst) choose = get_user_choice_by_menu(lst)
choose = terminal_menu.show()
return (choose) return (choose)
def site_editor(lst: list, database: Database): def site_editor(lst: list, database: Database):
global preview_database global preview_database
preview_database = database preview_database = database
terminal_menu = TerminalMenu(lst + ["", "quit"], choose = get_user_choice_by_menu(lst + ["", "quit"],
skip_empty_entries=True, skip_empty_entries=True,
show_search_hint=True, show_search_hint=True,
preview_title="Edit", title="Edit")
preview_command=config_preview)
choose = terminal_menu.show()
if (choose == len(lst) + 1): if (choose == len(lst) + 1):
return (None) return (None)
return (choose) return (choose)
def sites(sites: list): def sites(sites: list):
nb_site = len(sites) nb_site = len(sites)
terminal_menu = TerminalMenu(get(sites, "name") + ["", "add", "edit", "delete"], choose = get_user_choice_by_menu(get(sites, "name") + ["", "add", "edit", "delete"],
skip_empty_entries=True, skip_empty_entries=True,
show_search_hint=True) show_search_hint=True)
choose = terminal_menu.show()
return (choose) return (choose)

View File

@ -3,6 +3,8 @@ bs4==0.0.1
certifi==2023.5.7 certifi==2023.5.7
charset-normalizer==3.1.0 charset-normalizer==3.1.0
dbus-python==1.3.2 dbus-python==1.3.2
dumb-menu==1.0.7
getch==1.0
idna==3.4 idna==3.4
install==1.3.5 install==1.3.5
python-vlc==3.0.18122 python-vlc==3.0.18122