Skip to content

Commit 38e0ad5

Browse files
Filter of MAME BIOSes, Devices and Mechanical machines.
1 parent f99979c commit 38e0ad5

File tree

4 files changed

+80
-29
lines changed

4 files changed

+80
-29
lines changed

changelog.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ WIP [CORE] Filtering of BIOS/Devices not working properly for MAME ROMs.
5454
Use the offline scraper DB to determine what is a BIOS/Device in MAME.
5555
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2697000#pid2697000
5656

57-
WIP [CORE] Unified ROM artwork directory. This will require heavy changes in categories.xml.
58-
I still have to think how to properly implement this. This is related to the
59-
desing of a prototype Kodi games database.
60-
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2865413#pid2865413
61-
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2867785#pid2867785
62-
6357
WIP [CORE] Automatic generation of 3D Boxes using BoxFront and BoxSpine.
6458
Copy this feature from AML.
6559

@@ -74,7 +68,8 @@ WIP [CORE] Use Libretro_BIOS_cores.json for the Retroarch BIOS audit and no
7468
database. However, Libretro_BIOS_cores.json does not have the ROM size.
7569

7670
WIP [FAVOURITES] Change the way artwork is stored in Favourites, Launchers and
77-
Categories directories. Avoid using IDs in the artwork name unless absolutely necessary.
71+
Categories directories. Avoid using IDs in the artwork name unless absolutely
72+
necessary.
7873

7974
WIP [MULTIDISC] Edit multidisc ROMs. In general, improve the support for
8075
multidisc ROMs.
@@ -107,8 +102,6 @@ WIP [SCRAPERS] ScreenScraper must choose the correct artwork depending on t
107102
AEL must have an official list of regions/languages, extracted from the No-Intro/Redump
108103
DATs, to translate to ScreenScraper values.
109104

110-
WIP [SCRAPERS] MAME offline scraper: include NPlayers field. Take it from nplayers.ini
111-
112105
WIP [SCRAPERS] MAME offline scraper: include ESRB field. Take it from GameInfoDB.
113106

114107
WIP [SCRAPERS] MAME offline scraper: include plot field. Take it from GameInfoDB.
@@ -119,7 +112,13 @@ WIP [SCRAPERS] Persistent scraper cache browser. Ability to browse the stor
119112

120113
[B]Advanced Emulator Launcher | version 0.9.10 | xx April 2020[/B]
121114

122-
WIP [CORE] New fields in database to be prepared for the future.
115+
WIP [CORE] Unified ROM artwork directory. This will require heavy changes in categories.xml.
116+
I still have to think how to properly implement this. This is related to the
117+
desing of a prototype Kodi games database.
118+
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2865413#pid2865413
119+
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2867785#pid2867785
120+
121+
WIP [CORE] New fields in database to be prepared for the future. See NOTES.md
123122

124123
WIP [CORE] Support for Spines artwork. Support for BoxTextures artwork.
125124
Have a look at LaunchBox for other types of artwork that may be interesting.
@@ -165,6 +164,8 @@ FEATURE [CORE] Changed the Offline Scraper XML fields. Now the XML files are no
165164

166165
FEATURE [CORE] Update the platform icons. Github issue #112.
167166

167+
FEATURE [SCRAPERS] MAME offline scraper: include NPlayers field. Take it from nplayers.ini
168+
168169
FEATURE [SCRAPERS] Store when there is a bad JSON from the scrapers for further
169170
analysis. Working for ScreenScraper scraper.
170171

@@ -173,6 +174,9 @@ FEATURE [SCRAPERS] Update MAME Offline Scraper database to version latest versi
173174
FEATURE [SCRAPERS] Include isBIOS, isDevice, isMechanical in AOL MAME database. This is
174175
required to filter BIOSes and Devices in MAME launchers.
175176

177+
WIP [SCRAPERS] Filter MAME BIOSes, Devices and Mechanical machines with the new
178+
Offline Scraper JSON databases.
179+
176180
FEATURE [SCRAPERS] Add a delay of 1200 ms between downloads to ScreenScraper scraper
177181
to avoid scraper overloading. This is configurable in the scraper object.
178182
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2923181#pid2923181

resources/main.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9464,16 +9464,16 @@ def _roms_import_roms(self, launcherID):
94649464

94659465
# --- Open ROM scanner report file ---
94669466
launcher_report_FN = g_PATHS.REPORTS_DIR.pjoin(launcher['roms_base_noext'] + '_report.txt')
9467-
log_info('Report file OP "{0}"'.format(launcher_report_FN.getOriginalPath()))
9468-
log_info('Report file P "{0}"'.format(launcher_report_FN.getPath()))
9467+
log_info('Report file OP "{}"'.format(launcher_report_FN.getOriginalPath()))
9468+
log_info('Report file P "{}"'.format(launcher_report_FN.getPath()))
94699469
report_fobj = open(launcher_report_FN.getPath(), "w")
94709470
report_fobj.write('*** Starting ROM scanner ... ***\n'.format())
9471-
report_fobj.write('Launcher name "{0}"\n'.format(launcher['m_name']))
9472-
report_fobj.write('Launcher ID "{0}"\n'.format(launcher['id']))
9473-
report_fobj.write('ROM path "{0}"\n'.format(rom_path.getPath()))
9474-
report_fobj.write('ROM ext "{0}"\n'.format(launcher_exts))
9475-
report_fobj.write('ROM extra path "{0}"\n'.format(rom_extra_path.getPath()))
9476-
report_fobj.write('Platform "{0}"\n'.format(launcher['platform']))
9471+
report_fobj.write('Launcher name "{}"\n'.format(launcher['m_name']))
9472+
report_fobj.write('Launcher ID "{}"\n'.format(launcher['id']))
9473+
report_fobj.write('ROM path "{}"\n'.format(rom_path.getPath()))
9474+
report_fobj.write('ROM ext "{}"\n'.format(launcher_exts))
9475+
report_fobj.write('ROM extra path "{}"\n'.format(rom_extra_path.getPath()))
9476+
report_fobj.write('Platform "{}"\n'.format(launcher['platform']))
94779477

94789478
# Check if there is an XML for this launcher. If so, load it.
94799479
# If file does not exist or is empty then return an empty dictionary.
@@ -9494,14 +9494,17 @@ def _roms_import_roms(self, launcherID):
94949494
# Check if scraper is ready for operation. Otherwise disable it internally.
94959495
scraper_strategy.scanner_check_before_scraping()
94969496

9497+
# Create ROMFilter object. Loads filter databases for MAME.
9498+
romfilter = FilterROM(g_PATHS, self.settings, launcher['platform'])
9499+
94979500
# --- Assets/artwork stuff ----------------------------------------------------------------
94989501
# Ensure there is no duplicate asset dirs. Abort scanning of assets if duplicate dirs found.
94999502
log_debug('Checking for duplicated artwork directories...')
95009503
duplicated_name_list = asset_get_duplicated_dir_list(launcher)
95019504
if duplicated_name_list:
95029505
duplicated_asset_srt = ', '.join(duplicated_name_list)
9503-
log_info('Duplicated asset dirs: {0}'.format(duplicated_asset_srt))
9504-
kodi_dialog_OK('Duplicated asset directories: {0}. '.format(duplicated_asset_srt) +
9506+
log_info('Duplicated asset dirs: {}'.format(duplicated_asset_srt))
9507+
kodi_dialog_OK('Duplicated asset directories: {}. '.format(duplicated_asset_srt) +
95059508
'Change asset directories before continuing.')
95069509
return
95079510
else:
@@ -9513,7 +9516,7 @@ def _roms_import_roms(self, launcherID):
95139516
if scraper_strategy.unconfigured_name_list:
95149517
unconfigured_asset_srt = ', '.join(scraper_strategy.unconfigured_name_list)
95159518
kodi_dialog_OK(
9516-
'Assets directories not set: {0}. '.format(unconfigured_asset_srt) +
9519+
'Assets directories not set: {}. '.format(unconfigured_asset_srt) +
95179520
'Asset scanner will be disabled for this/those.')
95189521

95199522
# --- Create a cache of assets ---
@@ -9703,12 +9706,9 @@ def _roms_import_roms(self, launcherID):
97039706
report_fobj.write(' File not in launcher ROM list. Processing it ...\n')
97049707

97059708
# --- Ignore BIOS ROMs ---
9706-
# Name of bios is: '[BIOS] Rom name example (Rev A).zip'
9707-
if self.settings['scan_ignore_bios']:
9708-
BIOS_re = re.findall('\[BIOS\]', ROM.getBase())
9709-
if len(BIOS_re) > 0:
9710-
log_info("BIOS detected. Skipping ROM '{0}'".format(ROM.path))
9711-
continue
9709+
if romfilter.ROM_is_filtered(ROM.getBase()):
9710+
log_debug('ROM filtered.')
9711+
continue
97129712

97139713
# --- Create new ROM and process metadata and assets ---------------------------------
97149714
romdata = fs_new_rom()

resources/platforms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
DEFAULT_PLAT_MOBYGAMES = '0'
2929
DEFAULT_PLAT_SCREENSCRAPER = '0'
3030
DEFAULT_PLAT_GAMEFAQS = '0'
31+
PLATFORM_MAME_LONG = 'MAME'
32+
PLATFORM_MAME_SHORT = 'arcade-mame'
33+
PLATFORM_MAME_COMPACT = 'mame'
3134
PLATFORM_UNKNOWN_LONG = 'Unknown'
3235
PLATFORM_UNKNOWN_SHORT = 'unknown'
3336
PLATFORM_UNKNOWN_COMPACT = 'unknown'
@@ -222,7 +225,7 @@ def __init__(self, name, shortname, compactname, aliasof = None,
222225
DAT_NOINTRO, 'Magnavox - Odyssey2'),
223226

224227
# --- MAME/Arcade ---
225-
Platform('MAME', 'arcade-mame', 'mame', None, '23', '143', '75', '2', DAT_MAME),
228+
Platform(PLATFORM_MAME_LONG, PLATFORM_MAME_SHORT, PLATFORM_MAME_COMPACT, None, '23', '143', '75', '2', DAT_MAME),
226229

227230
# --- Mattel ---
228231
Platform('Mattel Intellivision', 'console-ivision', 'ivision', None, '32', '30', '115', '16',

resources/scrap.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,54 @@
142142
# used to filter MAME machines.
143143
# This class is (will be) used in the ROM Scanner.
144144
class FilterROM(object):
145-
def __init__(self, PATHS, settings):
145+
def __init__(self, PATHS, settings, platform):
146146
log_debug('FilterROM.__init__() BEGIN...')
147147
self.PATHS = PATHS
148148
self.settings = settings
149+
self.platform = platform
150+
self.addon_dir = self.settings['scraper_aeloffline_addon_code_dir']
151+
152+
# If platform is MAME load the BIOS, Devices and Mechanical databases.
153+
if self.platform == PLATFORM_MAME_LONG:
154+
BIOS_path = os.path.join(self.addon_dir, 'data-AOS', 'MAME_BIOSes.json')
155+
Devices_path = os.path.join(self.addon_dir, 'data-AOS', 'MAME_Devices.json')
156+
Mechanical_path = os.path.join(self.addon_dir, 'data-AOS', 'MAME_Mechanical.json')
157+
BIOS_list = self._load_JSON(BIOS_path)
158+
Devices_list = self._load_JSON(Devices_path)
159+
Mechanical_list = self._load_JSON(Mechanical_path)
160+
# Convert lists to sets to execute efficiently 'x in y' operation.
161+
self.BIOS_set = {i for i in BIOS_list}
162+
self.Devices_set = {i for i in Devices_list}
163+
self.Mechanical_set = {i for i in Mechanical_list}
164+
165+
def _load_JSON(self, filename):
166+
log_debug('FilterROM::_load_JSON() Loading "{}"'.format(filename))
167+
with open(filename) as file:
168+
data = json.load(file)
169+
170+
return data
171+
172+
# Returns True if ROM is filtered, False otherwise.
173+
def ROM_is_filtered(self, basename):
174+
if self.platform == PLATFORM_MAME_LONG:
175+
if basename in self.BIOS_set:
176+
log_debug('FilterROM::ROM_is_filtered() Filtered MAME BIOS "{}"'.format(basename))
177+
return True
178+
if basename in self.Devices_set:
179+
log_debug('FilterROM::ROM_is_filtered() Filtered MAME Device "{}"'.format(basename))
180+
return True
181+
if basename in self.Mechanical_set:
182+
log_debug('FilterROM::ROM_is_filtered() Filtered MAME Mechanical "{}"'.format(basename))
183+
return True
184+
else:
185+
# If it is not MAME it is No-Intro
186+
# Name of bios is: '[BIOS] Rom name example (Rev A).zip'
187+
BIOS_m = re.findall('\[BIOS\]', basename)
188+
if BIOS_m:
189+
log_debug('FilterROM::ROM_is_filtered() Filtered No-Intro BIOS "{}"'.format(basename))
190+
return True
191+
192+
return False
149193

150194
class ScraperFactory(object):
151195
def __init__(self, PATHS, settings):

0 commit comments

Comments
 (0)