Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- # === Valid extensions by default -Change and add yo your liking===
- rom_extensions = [
- ".nes", ".sfc", ".smc", ".gba", ".bin", ".cue", ".iso", ".img",
- ".zip", ".7z", ".gen", ".md", ".z64", ".pbp"
- ]
- # === Clean the label ===
- def clean_label(filename):
- return os.path.splitext(os.path.basename(filename))[0].lstrip("._")
- # === Base folder (run the script from here) ===
- root_dir = os.getcwd()
- # === Loop through each platform (subfolder of Games/) - Change path as needed ===
- for platform in os.listdir(root_dir):
- platform_path = os.path.join(root_dir, platform)
- if not os.path.isdir(platform_path) or platform.startswith("."):
- continue
- # Set base path for RetroArch on Android - Change path as needed
- retroarch_base = f"/storage/FCC5-19ED/Games/{platform}/"
- items = []
- # Walk through the platform folder recursively
- for dirpath, _, filenames in os.walk(platform_path):
- for filename in filenames:
- if filename.startswith("._"):
- continue
- ext = os.path.splitext(filename)[1].lower()
- # Special case: Only .cue files for PlayStation
- if platform.lower() in ["playstation", "ps1", "sony - playstation"]:
- if ext != ".cue":
- continue
- elif ext not in rom_extensions:
- continue
- full_path = os.path.join(dirpath, filename)
- relative_to_platform = os.path.relpath(full_path, platform_path)
- retroarch_path = retroarch_base + relative_to_platform.replace("\\", "/")
- items.append({
- "path": retroarch_path,
- "label": clean_label(filename),
- "core_path": "DETECT",
- "core_name": "DETECT",
- "crc32": "DETECT|crc",
- "db_name": f"{platform}.lpl"
- })
- # Build playlist JSON
- playlist = {
- "version": "1.5",
- "default_core_path": "",
- "default_core_name": "",
- "label_display_mode": 0,
- "right_thumbnail_mode": 0,
- "left_thumbnail_mode": 0,
- "sort_mode": 0,
- "items": items
- }
- # Save .lpl file
- output_path = os.path.join(root_dir, f"{platform}.lpl")
- with open(output_path, "w") as f:
- json.dump(playlist, f, indent=2)
- print(f"✅ Created playlist: {platform}.lpl with {len(items)} games.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement