Skip to content

Commit

Permalink
textual tui
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Jan 29, 2024
1 parent b5305d1 commit 12fd7ae
Show file tree
Hide file tree
Showing 27 changed files with 1,646 additions and 1,497 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
run: |
pip install poetry
poetry install
- run: poetry run pyright
- run: poetry run pyright sachi/
- run: poetry run ruff check sachi/
if: always()
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ cython_debug/
#.idea/

.DS_Store
/.vscode/launch.json
/media
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "textual_dev",
"args": ["run", "--dev", "sachi:SachiApp"],
"cwd": "${input:cwd}",
"preLaunchTask": "Textual Development Console",
"justMyCode": true
}
],
"inputs": [
{
"id": "cwd",
"description": "Current working directory",
"type": "promptString",
"default": "${workspaceFolder}/media"
}
]
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Textual Development Console",
"type": "process",
"command": "poetry",
"args": ["run", "textual", "console"],
"isBackground": true,
"presentation": {
"reveal": "always"
}
}
]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ COPY README.md .
RUN poetry install --only-root

ENV EDITOR=nvim
ENTRYPOINT [ "poetry", "run", "python3", "-m", "sachi" ]
ENTRYPOINT [ "poetry", "run", "sachi" ]
VOLUME [ "/root/.config/sachi" ]
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sachi

Sachi is a series and movie TUI (?) renamer. It aims to replace FileBot.
Sachi is a series and movie TUI renamer made with [Textual](https://github.com/textualize/textual/) which aims to replace FileBot.

![Demo](demo.gif)

Expand Down Expand Up @@ -36,6 +36,4 @@ In progress:

- FileBot context (https://www.filebot.net/naming.html)

A GUI is not planned. You are asked instead to edit multiple TOML files during the renaming process.

The global configuration can be edited with `sachi config` (also a TOML file).
The global configuration can be edited with `sachi config`.
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
982 changes: 666 additions & 316 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ readme = "README.md"
repository = "https://github.com/NextFire/sachi"

[tool.poetry.scripts]
sachi = "sachi:app"
sachi = "sachi:cli_app"

[tool.poetry.dependencies]
python = "~3.12"
typer = {extras = ["all"], version = "^0.9.0"}
inquirer = "^3.2.2"
textual = "^0.47.1"
tomlkit = "^0.12.3"
pydantic = "^2.5.3"
requests = "^2.31.0"
aiohttp = {extras = ["speedups"], version = "^3.9.2"}
yarl = "^1.9.4"
backoff = "^2.2.1"
pymediainfo = "^6.1.0"
jinja2 = "^3.1.3"
regex = "*"
pymediainfo = "^6.1.0"
guessit = "^3.8.0"

[tool.poetry.group.dev.dependencies]
pyright = "^1.1.348"
ruff = "^0.1.14"
textual-dev = "^1.4.0"

[build-system]
requires = ["poetry-core"]
Expand Down
8 changes: 4 additions & 4 deletions sachi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sachi.cli import app
from sachi.engine import SachiEngine
from sachi.app import SachiApp
from sachi.cli import cli_app

__all__ = [
"app",
"SachiEngine",
"SachiApp",
"cli_app",
]
4 changes: 2 additions & 2 deletions sachi/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sachi.cli import app
from sachi.cli import cli_app

if __name__ == "__main__":
app()
cli_app()
28 changes: 28 additions & 0 deletions sachi/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from pathlib import Path

from textual.app import App

from sachi.screens.episodes import EpisodesScreen
from sachi.screens.rename import RenameScreen


class SachiApp(App):
TITLE = "Sachi"
CSS_PATH = __file__.replace(".py", ".tcss")
SCREENS = {
"episodes": EpisodesScreen(),
}
BINDINGS = [
("1", "switch_screen('rename')", "Rename"),
("2", "switch_screen('episodes')", "Episodes"),
("q", "quit", "Quit"),
]

def __init__(self, file_or_dir: Path = Path.cwd(), **kwargs):
super().__init__(**kwargs)
self.file_or_dir = file_or_dir

def on_mount(self):
rename_screen = RenameScreen(self.file_or_dir)
self.install_screen(rename_screen, name="rename")
self.push_screen(rename_screen)
Empty file added sachi/app.tcss
Empty file.
29 changes: 7 additions & 22 deletions sachi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import typer

import sachi.resources
from sachi.app import SachiApp
from sachi.config import get_config_path
from sachi.engine import MediaType, SachiEngine

app = typer.Typer()
cli_app = typer.Typer()


@app.command()
@cli_app.command()
def config():
config_path = get_config_path()
if not config_path.exists():
Expand All @@ -23,8 +23,8 @@ def config():
typer.edit(filename=config_path.as_posix())


@app.command()
def series(
@cli_app.command()
def rename(
file_or_dir: Annotated[
Path,
typer.Argument(
Expand All @@ -36,20 +36,5 @@ def series(
),
],
):
SachiEngine(MediaType.SERIES)(file_or_dir)


@app.command()
def movie(
file_or_dir: Annotated[
Path,
typer.Argument(
exists=True,
file_okay=True,
dir_okay=False,
writable=True,
readable=True,
),
],
):
SachiEngine(MediaType.MOVIE)(file_or_dir)
app = SachiApp(file_or_dir)
app.run()
Loading

0 comments on commit 12fd7ae

Please sign in to comment.