Added scaning visualization
1 parent 2523b50 commit 9cbfdc2d5eb2a784bb1454c6e1a2fda6f19f1b9b
@eugene-sukhodolskiy eugene-sukhodolskiy authored on 1 Feb
Showing 10 changed files
View
4
app.py
@app.route('/media-list/clear-cache')
def media_list_clear_cache():
if GStorage["scaning_state"] == "inprogress":
return jsonify({"status": True})
 
media_remove_cache(config["cache_dir"], GStorage)
scan_medialib(config, GStorage, socketio)
return jsonify({"status": True})
 
filtered_files = media_get_from_cache(config["cache_dir"])
if filtered_files == None:
filtered_files = scan_medialib(config, GStorage, socketio)
 
if GStorage["scaning_state"] == "inprogress" and not len(filtered_files):
if GStorage["scaning_state"] == "inprogress" and filtered_files != None and not len(filtered_files):
response = {"status": "scaning", "data": []};
else:
response = {"status": True, "data": filtered_files}
return jsonify(response)
View
24
mediascan.py
 
 
 
# Function to list media files
def list_media_files(directories):
def list_media_files(socketio, directories):
media_files = []
for directory in directories:
if os.path.exists(directory):
for root, _, files in os.walk(directory):
for file in files:
for inx, file in enumerate(files):
file_path = os.path.join(root, file)
 
if not inx or not inx % 50:
socketio.emit("medialib-scaning-process", {
"message": f"Scaning: { directory }"
})
try:
file_info = {
"name": file,
"path": file_path,
 
 
def bg_scan_medialib(socketio, config, GStorage):
GStorage["scaning_state"] = "inprogress";
media_files = list_media_files(config.get("directories", []))
media_files = list_media_files(socketio, config.get("directories", []))
 
allowed_formats = config.get("allowed_formats", [])
socketio.emit("medialib-scaning-process", {
"message": f"Filtering by file extension..."
})
filtered_files = filter_media_files(media_files, allowed_formats)
socketio.emit("medialib-scaning-process", {
"message": f"Adding media file detail..."
})
 
# Add detailed media info
for file in filtered_files:
file["size"], file["size_unit"], file["size_bytes"] = human_readable_size(file["size"])
socketio.emit("medialib-scaning-process", {
"message": f"Adding detail: { file["path"] }"
})
file_info = get_media_info_with_ffprobe(file["path"])
if file_info:
file["info"] = file_info
else:
file["info"] = {"error": "Failed to retrieve media info"}
 
GStorage["scaning_state"] = "inaction"
socketio.emit("medialib-scaning-process", {
"message": f"Creating cache..."
})
media_create_cache(config["cache_dir"], filtered_files)
 
socketio.emit("medialib-scaning-complete", {
"data": filtered_files
View
scss/components/media-list.scss 0 → 100644
View
scss/index.scss
View
scss/main.scss
View
static/css/main.css
View
static/css/main.css.map
View
static/js/components/media-list.js
View
static/js/lib.js
View
templates/components/media-list.html