Skip to content

Commit

Permalink
294 pre-cursor to allow default selection per library (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
bullmoose20 authored Feb 24, 2025
1 parent 6268e8b commit f3e07da
Show file tree
Hide file tree
Showing 43 changed files with 531 additions and 203 deletions.
9 changes: 0 additions & 9 deletions modules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,6 @@ def update_checker_loop(app):
time.sleep(86400) # Sleep for 24 hours


def is_default_image(image_path):
try:
img = Image.open(image_path)
grey_img = Image.new("RGBA", (1000, 1500), (128, 128, 128, 255))
return list(img.getdata()) == list(grey_img.getdata())
except Exception:
return False


def enforce_string_fields(data, string_fields):
"""
Ensure specified fields in a dictionary are of type string.
Expand Down
33 changes: 27 additions & 6 deletions quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
check_for_update,
update_checker_loop,
booler,
is_default_image,
ensure_json_schema,
get_pyfiglet_fonts,
)
Expand Down Expand Up @@ -108,6 +107,7 @@
UPLOAD_FOLDER_SHOW = "config/uploads/shows"
os.makedirs(UPLOAD_FOLDER_MOVIE, exist_ok=True)
os.makedirs(UPLOAD_FOLDER_SHOW, exist_ok=True)
IMAGES_FOLDER = "static/images"
OVERLAY_FOLDER = "static/images/overlays"
PREVIEW_FOLDER = "config/previews"
os.makedirs(PREVIEW_FOLDER, exist_ok=True)
Expand Down Expand Up @@ -205,6 +205,11 @@ def rename_library_image():
return jsonify({"status": "error", "message": str(e)}), 500


@app.route("/config/uploads/<path:filename>")
def serve_uploaded_file(filename):
return send_from_directory(UPLOAD_FOLDER, filename)


@app.route("/config/previews/<path:filename>")
def serve_previews(filename):
return send_from_directory("config/previews", filename)
Expand All @@ -225,11 +230,25 @@ def generate_preview():
# Ensure preview folder exists
os.makedirs(preview_folder, exist_ok=True)

# ✅ First, check if `default.png` exists in `IMAGES_FOLDER`
default_image_path = os.path.join(IMAGES_FOLDER, "default.png")

if not selected_image or selected_image == "default":
base_image_path = os.path.join(preview_folder, "default_grey.png")
if not os.path.exists(base_image_path):
base_img = Image.new("RGBA", (1000, 1500), (128, 128, 128, 255))
base_img.save(base_image_path)
if os.path.exists(default_image_path):
base_image_path = default_image_path # ✅ Use existing `default.png`
else:
base_image_path = os.path.join(preview_folder, "default.png")

# ✅ Only create grey image if both locations are missing
if not os.path.exists(base_image_path):
if app.config["QS_DEBUG"]:
print(
"[DEBUG] default.png not found in IMAGES_FOLDER or previews, creating grey placeholder image..."
)

# Create grey image
base_img = Image.new("RGBA", (1000, 1500), (128, 128, 128, 255)) # grey
base_img.save(base_image_path)
else:
base_image_path = os.path.join(upload_folder, selected_image)

Expand All @@ -250,7 +269,9 @@ def generate_preview():

# Save the generated preview
base_img.save(preview_path)
print(f"[INFO] Preview saved at {preview_path}")

if app.config["QS_DEBUG"]:
print(f"[DEBUG] Preview saved at {preview_path}")

return jsonify({"status": "success", "preview_url": f"/{preview_path}"})

Expand Down
Binary file added static/images/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/au.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/commonsense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/de.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_aspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_audio_codec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_direct_play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_language_count.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_languages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_mediastinger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_ratings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_resolution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_ribbon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_runtimes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_streaming.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_studio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_versions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/mov-overlay_video_format.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/nz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/sho-overlay_aspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/sho-overlay_audio_codec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/sho-overlay_direct_play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/sho-overlay_language_count.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/sho-overlay_languages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/overlays/sho-overlay_mediastinger.png
Binary file modified static/images/overlays/sho-overlay_network.png
Binary file modified static/images/overlays/sho-overlay_ratings.png
Binary file modified static/images/overlays/sho-overlay_resolution.png
Binary file modified static/images/overlays/sho-overlay_ribbon.png
Binary file modified static/images/overlays/sho-overlay_runtimes.png
Binary file modified static/images/overlays/sho-overlay_status.png
Binary file modified static/images/overlays/sho-overlay_streaming.png
Binary file modified static/images/overlays/sho-overlay_studio.png
Binary file modified static/images/overlays/sho-overlay_versions.png
Binary file modified static/images/overlays/sho-overlay_video_format.png
Binary file modified static/images/overlays/uk.png
Binary file modified static/images/overlays/us_movie.png
Binary file modified static/images/overlays/us_show.png
Loading

0 comments on commit f3e07da

Please sign in to comment.