This commit is contained in:
2026-02-13 13:45:35 -08:00
parent 6416aeceec
commit ce2f28cc50
5 changed files with 99 additions and 24 deletions

View File

@@ -92,7 +92,7 @@
"(hitfile\\.net/[a-z0-9A-Z]{4,9})"
],
"regexp": "(hitf\\.(to|cc)/([a-z0-9A-Z]{4,9}))|(htfl\\.(net|to|cc)/([a-z0-9A-Z]{4,9}))|(hitfile\\.(net)/download/free/([a-z0-9A-Z]{4,9}))|((hitfile\\.net/[a-z0-9A-Z]{4,9}))",
"status": false
"status": true
},
"mega": {
"name": "mega",
@@ -481,7 +481,7 @@
"(katfile\\.com/[0-9a-zA-Z]{12})"
],
"regexp": "(katfile\\.(cloud|online)/([0-9a-zA-Z]{12}))|((katfile\\.com/[0-9a-zA-Z]{12}))",
"status": true
"status": false
},
"mediafire": {
"name": "mediafire",
@@ -493,7 +493,7 @@
"mediafire\\.com/(\\?|download/|file/|download\\.php\\?)([0-9a-z]{15})"
],
"regexp": "mediafire\\.com/(\\?|download/|file/|download\\.php\\?)([0-9a-z]{15})",
"status": false
"status": true
},
"mixdrop": {
"name": "mixdrop",

View File

@@ -47,6 +47,29 @@ import logging
logger = logging.getLogger(__name__)
_RESULT_TABLE_ROW_STYLE_LOOP: List[tuple[str, str]] = [
("#ff0000", "#8f00ff"),
("#ffa500", "#800080"),
("#ffff00", "#0000ff"),
("#808080", "#008000"),
("#008000", "#808080"),
("#0000ff", "#ffff00"),
("#800080", "#ffa500"),
("#8f00ff", "#ff0000"),
("#ffffff", "#000000"),
]
RESULT_TABLE_HEADER_STYLE = "bold #000000 on #ffffff"
RESULT_TABLE_BORDER_STYLE = "#000000 on #ffffff"
def get_result_table_row_style(row_index: int) -> str:
text_color, bg_color = _RESULT_TABLE_ROW_STYLE_LOOP[
row_index % len(_RESULT_TABLE_ROW_STYLE_LOOP)
]
return f"{text_color} on {bg_color}"
def _sanitize_cell_text(value: Any) -> str:
"""Coerce to a single-line, tab-free string suitable for terminal display."""
if value is None:
@@ -1194,10 +1217,11 @@ class Table:
if path_obj.suffix:
extension = path_obj.suffix.lstrip(".")
visible_data[title_field] = path_obj.stem
visible_data["ext"] = extension
# Preserve ext extracted from payload/metadata when present.
# Only use title suffix as fallback when ext is missing.
if not str(visible_data.get("ext") or "").strip():
visible_data["ext"] = extension
# print(f"DEBUG: Split extension. Title: {visible_data[title_field]}, Ext: {extension}")
else:
visible_data["ext"] = ""
# Ensure 'ext' is present so it gets picked up by priority_groups in correct order
if "ext" not in visible_data:
@@ -1345,7 +1369,15 @@ class Table:
"""Return a Rich renderable representing this table."""
if not self.rows:
empty = Text("No results")
return Panel(empty, title=self.title) if self.title else empty
return (
Panel(
empty,
title=Text(str(self.title), style=RESULT_TABLE_HEADER_STYLE),
border_style=RESULT_TABLE_BORDER_STYLE,
)
if self.title
else empty
)
col_names: List[str] = []
seen: Set[str] = set()
@@ -1357,7 +1389,8 @@ class Table:
table = RichTable(
show_header=True,
header_style="bold",
header_style=RESULT_TABLE_HEADER_STYLE,
border_style=RESULT_TABLE_BORDER_STYLE,
box=SIMPLE,
expand=True,
show_lines=False,
@@ -1387,12 +1420,20 @@ class Table:
for name in col_names:
val = row.get_column(name) or ""
cells.append(self._apply_value_case(_sanitize_cell_text(val)))
table.add_row(*cells)
table.add_row(*cells, style=get_result_table_row_style(row_idx - 1))
if self.title or self.header_lines:
header_bits = [Text(line) for line in (self.header_lines or [])]
renderable = Group(*header_bits, table) if header_bits else table
return Panel(renderable, title=self.title) if self.title else renderable
return (
Panel(
renderable,
title=Text(str(self.title), style=RESULT_TABLE_HEADER_STYLE),
border_style=RESULT_TABLE_BORDER_STYLE,
)
if self.title
else renderable
)
return table
@@ -2233,16 +2274,21 @@ class ItemDetailView(Table):
detail_title = str(self.detail_title or "Item Details").strip() or "Item Details"
elements.append(Panel(
details_table,
title=f"[bold green]{detail_title}[/bold green]",
border_style="green",
title=Text(detail_title, style=RESULT_TABLE_HEADER_STYLE),
border_style=RESULT_TABLE_BORDER_STYLE,
padding=(1, 2)
))
if results_renderable:
# If it's a Panel already (from super().to_rich() with title), use it directly
# but force the border style to green for consistency
# but force the border style to the result-table standard for consistency
if isinstance(results_renderable, Panel):
results_renderable.border_style = "green"
results_renderable.border_style = RESULT_TABLE_BORDER_STYLE
if results_renderable.title:
results_renderable.title = Text(
str(results_renderable.title),
style=RESULT_TABLE_HEADER_STYLE,
)
# Add a bit of padding inside if it contains a table
elements.append(results_renderable)
else:
@@ -2253,6 +2299,12 @@ class ItemDetailView(Table):
# Add a bit of padding
results_group = Group(Text(""), results_renderable, Text(""))
elements.append(Panel(results_group, title=display_title, border_style="green"))
elements.append(
Panel(
results_group,
title=Text(str(display_title), style=RESULT_TABLE_HEADER_STYLE),
border_style=RESULT_TABLE_BORDER_STYLE,
)
)
return Group(*elements)

View File

@@ -12,6 +12,11 @@ import logging
logger = logging.getLogger(__name__)
from SYS.result_table import (
RESULT_TABLE_BORDER_STYLE,
RESULT_TABLE_HEADER_STYLE,
get_result_table_row_style,
)
from SYS.result_table_api import ColumnSpec, ResultModel, ResultTable, Renderer
@@ -30,12 +35,16 @@ class RichRenderer(Renderer):
except Exception as exc:
raise RuntimeError("rich is required for RichRenderer") from exc
table = RichTable(show_header=True, header_style="bold")
table = RichTable(
show_header=True,
header_style=RESULT_TABLE_HEADER_STYLE,
border_style=RESULT_TABLE_BORDER_STYLE,
)
cols = list(columns)
for col in cols:
table.add_column(col.header)
for r in rows:
for row_idx, r in enumerate(rows):
cells = []
for col in cols:
try:
@@ -52,7 +61,7 @@ class RichRenderer(Renderer):
logger.exception("Column extractor failed for '%s': %s", col.header, exc)
cell = ""
cells.append(cell)
table.add_row(*cells)
table.add_row(*cells, style=get_result_table_row_style(row_idx))
return table

19
TUI.py
View File

@@ -8,6 +8,7 @@ import sys
import subprocess
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple
from rich.text import Text
from textual import on, work
from textual.app import App, ComposeResult
@@ -41,7 +42,7 @@ for path in (REPO_ROOT, TUI_DIR):
sys.path.insert(0, str_path)
from TUI.pipeline_runner import PipelineRunResult # type: ignore # noqa: E402
from SYS.result_table import Table, extract_hash_value, extract_store_value # type: ignore # noqa: E402
from SYS.result_table import Table, extract_hash_value, extract_store_value, get_result_table_row_style # type: ignore # noqa: E402
from SYS.config import load_config # type: ignore # noqa: E402
from SYS.database import db
@@ -920,7 +921,12 @@ class PipelineHubApp(App):
if self.current_result_table.rows:
rows = self.current_result_table.to_datatable_rows()
for idx, row_values in enumerate(rows, 1):
self.results_table.add_row(str(idx), *row_values, key=str(idx - 1))
row_style = get_result_table_row_style(idx - 1)
self.results_table.add_row(
Text(str(idx), style=row_style),
*[Text(str(value), style=row_style) for value in row_values],
key=str(idx - 1),
)
else:
# Fallback or empty state
self.results_table.add_columns("Row", "Title", "Source", "File")
@@ -930,11 +936,12 @@ class PipelineHubApp(App):
# Fallback for items without a table
for idx, item in enumerate(self.result_items, start=1):
row_style = get_result_table_row_style(idx - 1)
self.results_table.add_row(
str(idx),
str(item),
"",
"",
Text(str(idx), style=row_style),
Text(str(item), style=row_style),
Text("", style=row_style),
Text("", style=row_style),
key=str(idx - 1)
)

View File

@@ -116,6 +116,13 @@
#results-table {
height: 1fr;
border: solid #ffffff;
}
#results-table > .datatable--header {
background: #ffffff;
color: #000000;
text-style: bold;
}