mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 19:43:28 +00:00
- Updated `pyproject.toml` to reflect new package structure. - Created `renamer/__init__.py` to initialize the package. - Implemented `RenamerApp` in `renamer/app.py` for the main application interface. - Added constants for video extensions in `renamer/constants.py`. - Developed `MediaExtractor` class in `renamer/extractor.py` for extracting metadata from media files. - Created various extractor classes in `renamer/extractors/` for handling filename, metadata, and media info extraction. - Added formatting classes in `renamer/formatters/` for displaying media information and proposed filenames. - Implemented utility functions in `renamer/utils.py` for detecting file types and extracting media track information. - Introduced `OpenScreen` in `renamer/screens.py` for user input of directory paths. - Enhanced error handling and user feedback throughout the application.
30 lines
960 B
Python
30 lines
960 B
Python
from textual.screen import Screen
|
|
from textual.widgets import Input, Button
|
|
from pathlib import Path
|
|
|
|
|
|
class OpenScreen(Screen):
|
|
def compose(self):
|
|
yield Input(placeholder="Enter directory path", value=".", id="dir_input")
|
|
yield Button("OK", id="ok")
|
|
|
|
def on_button_pressed(self, event):
|
|
if event.button.id == "ok":
|
|
self.submit_path()
|
|
|
|
def on_input_submitted(self, event):
|
|
self.submit_path()
|
|
|
|
def submit_path(self):
|
|
path_str = self.query_one("#dir_input", Input).value
|
|
path = Path(path_str)
|
|
if not path.exists():
|
|
# Show error
|
|
self.query_one("#dir_input", Input).value = f"Path does not exist: {path_str}"
|
|
return
|
|
if not path.is_dir():
|
|
self.query_one("#dir_input", Input).value = f"Not a directory: {path_str}"
|
|
return
|
|
self.app.scan_dir = path
|
|
self.app.scan_files()
|
|
self.app.pop_screen() |