Skip to content

Commit 5d4d80d

Browse files
Fixes scraping ROM metadata using CM. Github issue #146
1 parent a5737fe commit 5d4d80d

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,14 @@ FIX Fix crash when reading a launcher NFO file when importing a launcher XM
156156
Refactored the NFO file functions a bit.
157157
See https://forum.kodi.tv/showthread.php?tid=287826&pid=3045045#pid3045045
158158

159+
FIX Error when scraping metadata.
160+
See https://github.com/Wintermute0110/plugin.program.AEL/issues/146
161+
159162

160163
[B]Advanced Emulator Launcher | version 0.9.11 | xx xxxxxx 2021[/B]
161164

162165
NOTE This version is feature identical to 0.10.1
166+
Main development is in the Pyhton 3 branch.
163167

164168

165169
[B]Advanced Emulator Launcher | version 0.10.0 | 22 June 2021[/B]

resources/main.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,21 +2860,20 @@ def _command_edit_rom(self, categoryID, launcherID, romID):
28602860
scraper_index = mindex2 - len(common_menu_list)
28612861
scraper_ID = g_scrap_factory.get_metadata_scraper_ID_from_menu_idx(scraper_index)
28622862

2863-
# --- Grab data ---
2864-
object_dic = roms[romID]
2865-
ROM = FileName(roms[romID]['filename'])
2863+
# Prepare data for scraping.
2864+
rom = roms[romID]
2865+
ROM_FN = FileName(rom['filename'])
2866+
if rom['disks']:
2867+
ROM_hash_FN = FileName(ROM_FN.getDir()).pjoin(rom['disks'][0])
2868+
else:
2869+
ROM_hash_FN = ROM_FN
28662870
if categoryID == VCATEGORY_FAVOURITES_ID or categoryID == VCATEGORY_COLLECTIONS_ID:
2867-
platform = roms[romID]['platform']
2871+
platform = rom['platform']
28682872
else:
28692873
platform = self.launchers[launcherID]['platform']
2870-
if roms[romID]['disks']:
2871-
# Multidisc ROM. Take first file of the set.
2872-
ROM_checksums_FN = FileName(ROM.getDir()).pjoin(roms[romID]['disks'][0])
2873-
else:
2874-
ROM_checksums_FN = ROM
28752874
data_dic = {
2876-
'rom_FN' : ROM,
2877-
'rom_checksums_FN' : ROM_checksums_FN,
2875+
'ROM_FN' : ROM_FN,
2876+
'ROM_hash_FN' : ROM_hash_FN,
28782877
'platform' : platform,
28792878
}
28802879

@@ -2886,7 +2885,7 @@ def _command_edit_rom(self, categoryID, launcherID, romID):
28862885
# Remember to flush caches after scraping.
28872886
st_dic = kodi_new_status_dic()
28882887
s_strategy = g_scrap_factory.create_CM_metadata(scraper_ID, platform)
2889-
s_strategy.scrap_CM_metadata_ROM(object_dic, data_dic, st_dic)
2888+
s_strategy.scrap_CM_metadata_ROM(rom, data_dic, st_dic)
28902889
g_scrap_factory.destroy_CM()
28912890
if kodi_display_status_message(st_dic): return
28922891

@@ -3000,9 +2999,7 @@ def _command_edit_rom(self, categoryID, launcherID, romID):
30002999
ROM_hash_FN = FileName(ROM_FN.getDir()).pjoin(rom['disks'][0])
30013000
else:
30023001
ROM_hash_FN = ROM_FN
3003-
if categoryID == VCATEGORY_FAVOURITES_ID:
3004-
platform = rom['platform']
3005-
elif categoryID == VCATEGORY_COLLECTIONS_ID:
3002+
if categoryID == VCATEGORY_FAVOURITES_ID or categoryID == VCATEGORY_COLLECTIONS_ID:
30063003
platform = rom['platform']
30073004
else:
30083005
platform = self.launchers[launcherID]['platform']

resources/scrap.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,7 @@ def _apply_candidate_on_metadata_new(self, gamedata, rom):
10741074
def scrap_CM_metadata_ROM(self, object_dic, data_dic, st_dic):
10751075
log_debug('ScrapeStrategy.scrap_CM_metadata_ROM() BEGIN ...')
10761076
# In AEL 0.10.x this data is grabed from the objects, not passed using a dictionary.
1077-
rom_FN = data_dic['rom_FN']
1078-
rom_base_noext = rom_FN.getBaseNoExt()
1077+
rom_base_noext = data_dic['ROM_FN'].getBaseNoExt()
10791078
scraper_name = self.scraper_obj.get_name()
10801079

10811080
# --- Check if scraper is OK (API keys configured, etc.) ---
@@ -1222,14 +1221,14 @@ def scrap_CM_asset_all(self, object_dic, data_dic, st_dic):
12221221
def _scrap_CM_get_candidate(self, object_name, object_dic, data_dic, st_dic):
12231222
# log_debug('ScrapeStrategy._scrap_CM_get_candidate() BEGIN...')
12241223

1225-
# In AEL 0.10.x this data is grabed from the objects, not passed using a dictionary.
1224+
# In AEL 0.10.x this data is grabbed from the objects, not passed using a dictionary.
12261225
ROM_FN = data_dic['ROM_FN']
12271226
ROM_hash_FN = data_dic['ROM_hash_FN']
12281227
platform = data_dic['platform']
12291228
scraper_name = self.scraper_obj.get_name()
12301229

12311230
# * Note that empty candidates may be in the cache. An empty candidate means that
1232-
# the scraper search was unsucessful. For some scrapers, changing the search
1231+
# the scraper search was unsuccessful. For some scrapers, changing the search
12331232
# string may produce a valid candidate.
12341233
# * In the context menu always rescrape empty candidates.
12351234
# * In the ROM scanner empty candidates are never rescraped. In that cases
@@ -1458,7 +1457,7 @@ class Scraper(object):
14581457
# the number of API calls is exceeded).
14591458
EXCEPTION_COUNTER_THRESHOLD = 5
14601459

1461-
# Disk cache types. These string will be part of the cache file names.
1460+
# Disk cache types. These strings will be part of the cache JSON file names.
14621461
CACHE_CANDIDATES = 'candidates'
14631462
CACHE_METADATA = 'metadata'
14641463
CACHE_ASSETS = 'assets'

0 commit comments

Comments
 (0)