Compare commits

..

5 Commits

Author SHA1 Message Date
1c5b5d8299 testing 2025-12-07 23:00:38 +01:00
b5be627097 added textual-dev as dependency and initiated main.py 2025-12-07 12:10:43 +01:00
51410b3321 Added init and main 2025-12-07 12:02:53 +01:00
c44f5de168 adding logger 2025-12-07 12:01:40 +01:00
8cbbf171f2 first commit 2025-12-07 11:54:58 +01:00
7 changed files with 71 additions and 1 deletions

View File

@@ -1,3 +1,13 @@
# ytdlp-tui
A TUI wrapper for my yt-dlp commands
This is a little tool to collect all my yt-dlp commands in one CLI app.
It aims to teach me how to write an TUI application in python.
## Libaries used
- pytest
- textual
- textual-dev (for command line development)

0
pyproject.toml Normal file
View File

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
pytest
textual
textual-dev

0
src/dl-tui/__init__.py Normal file
View File

20
src/dl-tui/ytdlp-tui.py Normal file
View File

@@ -0,0 +1,20 @@
# from dllib.logger import logger
from textual.app import App, ComposeResult
from textual.widgets import Label, Button
class QuestionApp(App[str]):
def compose(self) -> ComposeResult:
yield Label("Do you love Textual?")
yield Button("Yes", id="yes", variant="primary")
yield Button("No", id="no", variant="error")
def on_button_pressed(self, event: Button.Pressed) -> None:
self.exit(event.button.id)
if __name__ == "__main__":
app = QuestionApp()
reply = app.run()
print(reply)

0
src/dllib/__init__.py Normal file
View File

37
src/dllib/logger.py Normal file
View File

@@ -0,0 +1,37 @@
import logging
import sys
from pathlib import Path
# Sets the directory of the logfile and creates the file if it doesnt
# already exist.
LOG_DIR = Path.home() / ".local" / "share" / "ytdlp-tui"
LOG_DIR.mkdir(
parents=True,
exist_ok=True,
)
LOG_FILE = LOG_DIR / "ytdlp-tui.log"
# Initilize the logger and formatting the output which gets written to
# the log.
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s",
filename=LOG_FILE,
)
logger = logging.getLogger()
# Catches Python errors and adds them to the log file instead of
# outputting it to the terminal.
def handle_exception(exec_type, exec_value, exec_traceback):
if issubclass(exec_type, KeyboardInterrupt):
sys.__excepthook__(exec_type, exec_value, exec_traceback)
return
logger.error(
"External error accured",
exc_info=(exec_type, exec_value, exec_traceback),
)
sys.excepthook = handle_exception