mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-26 05:37:20 -05:00
feat: add knulli, amberelec and emuelec platforms
Each OS publishes Batocera's systems dict (knulli-systems, and batocera-systems at AmberELEC's newest prerelease commit and EmuELEC v4.8), read with the shared parser. Cores come from each OS's own ES list. AmberELEC and EmuELEC declare neogeo/ and ports/ beside bios/ from /storage/roms, so their packs extract there and core_destination puts core files under bios/.
This commit is contained in:
1 parent
2fc62bd249
commit
2bdac466a9
18 files changed
+12933
-24
No files matched your search
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Scraper for KNULLI's knulli-systems.
|
||||
|
||||
Source: package/system/knulli-scripts/scripts/knulli-systems
|
||||
Format: Python source, Batocera's `systems` dict, parsed by batocera_scraper
|
||||
Hash: MD5
|
||||
|
||||
`msx1` and `msx2+` are written twice in the dict. Python keeps the later
|
||||
value of a repeated key when the script runs, and so does the parser.
|
||||
|
||||
Verification (knulli-systems at the release tag):
|
||||
- checkBios (lines 867-927): md5sum() of the file at /userdata/<file>
|
||||
against the declared md5, an empty md5 meaning presence only. For a
|
||||
zippedFile entry, checkInsideZip() (lines 814-845) matches the member name
|
||||
with casefold() and hashes it. A system or file carrying `emulator` and
|
||||
`core` is checked only when es_systems.cfg offers that pair (coreExists,
|
||||
lines 847-865).
|
||||
- Run by EmulationStation's BIOS screen (knulli-cfw/batocera-emulationstation
|
||||
10834d00, es-app/src/ApiSystem.cpp:764-774) and by knulli-support:69.
|
||||
|
||||
es_systems.yml and configgen-defaults.yml have Batocera's shape, so the cores
|
||||
are read with Batocera's code. The configgen generators do not: the hatari,
|
||||
melonds and gsplus generators and libretroOptions.py are older forms than the
|
||||
ones batocera_launchers reads, so no launcher layer is written.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
from .base_scraper import BaseScraper, BiosRequirement, fetch_github_latest_version
|
||||
from .batocera_scraper import (
|
||||
SYSTEM_SLUG_MAP as BATOCERA_SLUGS,
|
||||
)
|
||||
from .batocera_scraper import (
|
||||
_not_cores,
|
||||
configgen_cores,
|
||||
extract_systems_dict,
|
||||
platform_systems,
|
||||
requirements_from_systems,
|
||||
)
|
||||
|
||||
PLATFORM_NAME = "knulli"
|
||||
|
||||
REPO = "knulli-cfw/knulli-linux"
|
||||
_RAW = "https://raw.githubusercontent.com/knulli-cfw/knulli-linux/{ref}/"
|
||||
SOURCE_TEMPLATE = _RAW + "package/system/knulli-scripts/scripts/knulli-systems"
|
||||
CONFIGGEN_DEFAULTS_TEMPLATE = (
|
||||
_RAW + "package/system/knulli-configgen/configs/configgen-defaults.yml"
|
||||
)
|
||||
ES_SYSTEMS_TEMPLATE = _RAW + "package/emulationstation/knulli-es-system/es_systems.yml"
|
||||
|
||||
# Batocera's names, plus the keys KNULLI writes that Batocera does not,
|
||||
# filed under the slug the other scrapers already give them. msu-md holds the
|
||||
# Mega-CD BIOS files Batocera files under megadrive-msu.
|
||||
SYSTEM_SLUG_MAP = {
|
||||
**BATOCERA_SLUGS,
|
||||
"o2em": "magnavox-odyssey2",
|
||||
"msu-md": "sega-mega-cd",
|
||||
"xbox": "microsoft-xbox",
|
||||
}
|
||||
|
||||
|
||||
class Scraper(BaseScraper):
|
||||
"""Scraper for KNULLI's knulli-systems."""
|
||||
|
||||
def __init__(self, url: str | None = None) -> None:
|
||||
self.tag = "" if url else fetch_github_latest_version(REPO)
|
||||
super().__init__(url=url or SOURCE_TEMPLATE.format(ref=self.tag))
|
||||
|
||||
def _fetch_text(self, url: str) -> str:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "retrobios-scraper/1.0"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
return resp.read().decode("utf-8")
|
||||
except urllib.error.URLError as e:
|
||||
raise ConnectionError(f"Failed to fetch {url}: {e}") from e
|
||||
|
||||
def validate_format(self, raw_data: str) -> bool:
|
||||
has_dict = re.search(r"^systems\s*=\s*\{", raw_data, re.MULTILINE) is not None
|
||||
return has_dict and "def checkBios" in raw_data and '"biosFiles"' in raw_data
|
||||
|
||||
def fetch_requirements(self) -> list[BiosRequirement]:
|
||||
raw = self._fetch_raw()
|
||||
if not self.validate_format(raw):
|
||||
raise ValueError("knulli-systems format validation failed")
|
||||
return requirements_from_systems(extract_systems_dict(raw), SYSTEM_SLUG_MAP)
|
||||
|
||||
def generate_platform_yaml(self) -> dict:
|
||||
systems = platform_systems(
|
||||
self.fetch_requirements(), extract_systems_dict(self._fetch_raw()), SYSTEM_SLUG_MAP
|
||||
)
|
||||
# es_systems.yml files machine selectors and plugins under an
|
||||
# emulator as Batocera's does: Batocera's list of them applies.
|
||||
cores, standalone, dual = configgen_cores(
|
||||
self._fetch_text(CONFIGGEN_DEFAULTS_TEMPLATE.format(ref=self.tag)),
|
||||
self._fetch_text(ES_SYSTEMS_TEMPLATE.format(ref=self.tag)),
|
||||
_not_cores("batocera"),
|
||||
)
|
||||
result = {
|
||||
"platform": "KNULLI",
|
||||
"version": self.tag,
|
||||
"homepage": "https://knulli.org",
|
||||
"source": self.url,
|
||||
"base_destination": "bios",
|
||||
"hash_type": "md5",
|
||||
"verification_mode": "md5",
|
||||
"cores": cores,
|
||||
"systems": systems,
|
||||
}
|
||||
if standalone:
|
||||
result["standalone_cores"] = standalone
|
||||
if dual:
|
||||
result["dual_mode_cores"] = dual
|
||||
return result
|
||||
|
||||
|
||||
def main() -> None:
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape KNULLI BIOS requirements")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user