Compare commits
5 Commits
adc97858cb
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c5b5d8299 | |||
| b5be627097 | |||
| 51410b3321 | |||
| c44f5de168 | |||
| 8cbbf171f2 |
10
README.md
10
README.md
@@ -1,3 +1,13 @@
|
|||||||
# ytdlp-tui
|
# ytdlp-tui
|
||||||
|
|
||||||
A TUI wrapper for my yt-dlp commands
|
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
0
pyproject.toml
Normal file
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pytest
|
||||||
|
textual
|
||||||
|
textual-dev
|
||||||
0
src/dl-tui/__init__.py
Normal file
0
src/dl-tui/__init__.py
Normal file
20
src/dl-tui/ytdlp-tui.py
Normal file
20
src/dl-tui/ytdlp-tui.py
Normal 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
0
src/dllib/__init__.py
Normal file
37
src/dllib/logger.py
Normal file
37
src/dllib/logger.py
Normal 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
|
||||||
Reference in New Issue
Block a user