Update app.py
Browse files
app.py
CHANGED
|
@@ -42,8 +42,14 @@ def list_files():
|
|
| 42 |
|
| 43 |
df = pd.DataFrame(data)
|
| 44 |
if not df.empty:
|
| 45 |
-
#
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Default sort by File Name (alphabetical)
|
| 49 |
df = df.sort_values(by="File Name", ascending=True)
|
|
@@ -79,7 +85,8 @@ def download_file(filename):
|
|
| 79 |
return None
|
| 80 |
|
| 81 |
# --- UI LAYOUT ---
|
| 82 |
-
|
|
|
|
| 83 |
gr.Markdown("# ๐๏ธ AudioNovel Bucket Explorer")
|
| 84 |
gr.Markdown("View, sort, and download your processed audio files. **Click the column headers below to sort by Name, Date, or Size.**")
|
| 85 |
|
|
@@ -113,4 +120,5 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo")) as app:
|
|
| 113 |
app.load(fn=list_files, inputs=[], outputs=[file_table, file_dropdown])
|
| 114 |
|
| 115 |
if __name__ == "__main__":
|
| 116 |
-
|
|
|
|
|
|
| 42 |
|
| 43 |
df = pd.DataFrame(data)
|
| 44 |
if not df.empty:
|
| 45 |
+
# Safely convert to datetime using errors='coerce' to turn "Unknown" into NaT (Not a Time)
|
| 46 |
+
dt_col = pd.to_datetime(df["Last Modified"], errors='coerce')
|
| 47 |
+
|
| 48 |
+
# Remove timezone info for clean sorting/display
|
| 49 |
+
dt_col = dt_col.dt.tz_localize(None)
|
| 50 |
+
|
| 51 |
+
# Convert back to a clean string format, replacing NaT back with "Unknown" for the UI
|
| 52 |
+
df["Last Modified"] = dt_col.dt.strftime('%Y-%m-%d %H:%M:%S').fillna("Unknown")
|
| 53 |
|
| 54 |
# Default sort by File Name (alphabetical)
|
| 55 |
df = df.sort_values(by="File Name", ascending=True)
|
|
|
|
| 85 |
return None
|
| 86 |
|
| 87 |
# --- UI LAYOUT ---
|
| 88 |
+
# Theme moved from here to the launch command at the bottom
|
| 89 |
+
with gr.Blocks() as app:
|
| 90 |
gr.Markdown("# ๐๏ธ AudioNovel Bucket Explorer")
|
| 91 |
gr.Markdown("View, sort, and download your processed audio files. **Click the column headers below to sort by Name, Date, or Size.**")
|
| 92 |
|
|
|
|
| 120 |
app.load(fn=list_files, inputs=[], outputs=[file_table, file_dropdown])
|
| 121 |
|
| 122 |
if __name__ == "__main__":
|
| 123 |
+
# Theme is applied here now to avoid the Gradio 6.0 warning
|
| 124 |
+
app.launch(theme=gr.themes.Soft(primary_hue="indigo"))
|