Skip to content

Commit ee7440a

Browse files
Fixes from the Python 3 branch.
1 parent a5cedbc commit ee7440a

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed

changelog.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ WIP FIX Fix launching of ROMs with Windows network filenames.
150150
See https://forum.kodi.tv/showthread.php?tid=287826&pid=2919639#pid2919639
151151

152152

153+
[B]Advanced Emulator Launcher | version 0.10.1 | xx xxxxxx 2021[/B]
154+
155+
FIX Fix crash when reading a launcher NFO file when importing a launcher XML file.
156+
Refactored the NFO file functions a bit.
157+
See https://forum.kodi.tv/showthread.php?tid=287826&pid=3045045#pid3045045
158+
159+
160+
[B]Advanced Emulator Launcher | version 0.9.11 | xx xxxxxx 2021[/B]
161+
162+
NOTE This version is feature identical to 0.10.1
163+
164+
153165
[B]Advanced Emulator Launcher | version 0.10.0 | 22 June 2021[/B]
154166

155167
NOTE Python 3 version for Matrix in branch release-0.10.x-python3

resources/autoconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ def autoconfig_import_launcher(ROMS_DIR, categories, launchers, categoryID, laun
593593
launchers[launcherID]['m_name'] = i_launcher['name']
594594
log_debug('Imported m_name "{}"'.format(i_launcher['name']))
595595

596-
# >> Process <Launcher_NFO> before any metadata tag
596+
# Process <Launcher_NFO> before any metadata tag
597597
if i_launcher['Launcher_NFO']:
598-
log_debug('Imported Launcher_NFO "{}"'.format(i_launcher['Launcher_NFO']))
598+
log_debug('Processing <Launcher_NFO> "{}"'.format(i_launcher['Launcher_NFO']))
599599
Launcher_NFO_FN = FileName(import_FN.getDir()).pjoin(i_launcher['Launcher_NFO'])
600600
Launcher_NFO_meta = fs_read_launcher_NFO(Launcher_NFO_FN)
601601
log_debug('NFO year "{}"'.format(Launcher_NFO_meta['year']))

resources/disk_IO.py

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,7 @@ def fs_import_ROM_NFO(roms, romID, verbose = True):
11631163
# We assume NFO files are UTF-8. Decode data to Unicode.
11641164
#
11651165
# Future work: ESRB and maybe nplayers fields must be sanitized.
1166-
nfo_str = utils_load_file_to_str(nfo_file_path)
1167-
nfo_str = nfo_str.replace('\r', '').replace('\n', '')
1166+
nfo_str = utils_load_file_to_str(nfo_file_path).replace('\r', '').replace('\n', '')
11681167

11691168
# Read XML tags in the NFO single-line string and edit fields in the ROM dictionary.
11701169
update_dic_with_NFO_str(nfo_str, 'title', nfo_dic, 'm_name')
@@ -1195,26 +1194,24 @@ def fs_import_ROM_NFO_file_scanner(NFO_FN):
11951194
}
11961195

11971196
# Read file, put in a string and remove line endings to get a single-line string.
1198-
nfo_str = utils_load_file_to_str(NFO_FN.getPath())
1199-
nfo_str = nfo_str.replace('\r', '').replace('\n', '')
1197+
nfo_str = utils_load_file_to_str(NFO_FN.getPath()).replace('\r', '').replace('\n', '')
12001198

12011199
# Read XML tags in the NFO single-line string and edit fields in the ROM dictionary.
1202-
update_dic_with_NFO_str(nfo_str, 'title', nfo_dic, 'm_name')
1203-
update_dic_with_NFO_str(nfo_str, 'year', nfo_dic, 'm_year')
1204-
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'm_genre')
1205-
update_dic_with_NFO_str(nfo_str, 'developer', nfo_dic, 'm_developer')
1206-
update_dic_with_NFO_str(nfo_str, 'nplayers', nfo_dic, 'm_nplayers')
1207-
update_dic_with_NFO_str(nfo_str, 'esrb', nfo_dic, 'm_esrb')
1208-
update_dic_with_NFO_str(nfo_str, 'rating', nfo_dic, 'm_rating')
1209-
update_dic_with_NFO_str(nfo_str, 'plot', nfo_dic, 'm_plot')
1200+
update_dic_with_NFO_str(nfo_str, 'title', nfo_dic, 'title')
1201+
update_dic_with_NFO_str(nfo_str, 'year', nfo_dic, 'year')
1202+
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'genre')
1203+
update_dic_with_NFO_str(nfo_str, 'developer', nfo_dic, 'developer')
1204+
update_dic_with_NFO_str(nfo_str, 'nplayers', nfo_dic, 'nplayers')
1205+
update_dic_with_NFO_str(nfo_str, 'esrb', nfo_dic, 'esrb')
1206+
update_dic_with_NFO_str(nfo_str, 'rating', nfo_dic, 'rating')
1207+
update_dic_with_NFO_str(nfo_str, 'plot', nfo_dic, 'plot')
12101208

12111209
return nfo_dic
12121210

12131211
# Returns a FileName object
12141212
def fs_get_ROM_NFO_name(rom):
12151213
ROMFileName = FileName(rom['filename'])
12161214
nfo_FN = FileName(ROMFileName.getPathNoExt() + '.nfo')
1217-
12181215
return nfo_FN
12191216

12201217
# Standalone launchers: NFO files are stored in self.settings["launchers_nfo_dir"] if not empty.
@@ -1255,8 +1252,7 @@ def fs_import_launcher_NFO(nfo_FN, launchers, launcherID):
12551252
return False
12561253

12571254
# Read file, put in a single-line string and remove all line endings.
1258-
nfo_str = utils_load_file_to_str(nfo_FN.getPath())
1259-
nfo_str = nfo_str.replace('\r', '').replace('\n', '')
1255+
nfo_str = utils_load_file_to_str(nfo_FN.getPath()).replace('\r', '').replace('\n', '')
12601256
update_dic_with_NFO_str(nfo_str, 'year', nfo_dic, 'm_year')
12611257
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'm_genre')
12621258
update_dic_with_NFO_str(nfo_str, 'developer', nfo_dic, 'm_developer')
@@ -1267,7 +1263,7 @@ def fs_import_launcher_NFO(nfo_FN, launchers, launcherID):
12671263
# Used by autoconfig_import_launcher(). Returns a dictionary with the Launcher NFO file information.
12681264
# If there is any error return a dictionary with empty information.
12691265
def fs_read_launcher_NFO(nfo_FN):
1270-
launcher_dic = {
1266+
nfo_dic = {
12711267
'year' : '',
12721268
'genre' : '',
12731269
'developer' : '',
@@ -1276,21 +1272,19 @@ def fs_read_launcher_NFO(nfo_FN):
12761272
}
12771273

12781274
log_debug('fs_read_launcher_NFO() Importing "{}"'.format(nfo_FN.getPath()))
1279-
# Return a dictionary with empty values if file not found.
12801275
if not os.path.isfile(nfo_FN.getPath()):
12811276
kodi_notify_warn('NFO file not found {}'.format(os.path.basename(nfo_FN.getPath())))
1282-
log_info("fs_read_launcher_NFO() NFO file not found '{}'".format(nfo_FN.getPath()))
1283-
return launcher_dic
1284-
1285-
# Read file, put in a single-line string and remove all line endings.
1286-
nfo_str = utils_load_file_to_str(nfo_FN.getPath())
1287-
nfo_str = nfo_str.replace('\r', '').replace('\n', '')
1288-
update_dic_with_NFO_str(nfo_str, 'year', nfo_dic, 'm_year')
1289-
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'm_genre')
1290-
update_dic_with_NFO_str(nfo_str, 'developer', nfo_dic, 'm_developer')
1291-
update_dic_with_NFO_str(nfo_str, 'rating', nfo_dic, 'm_rating')
1292-
update_dic_with_NFO_str(nfo_str, 'plot', nfo_dic, 'm_plot')
1293-
return launcher_dic
1277+
log_info('fs_read_launcher_NFO() NFO file not found "{}"'.format(nfo_FN.getPath()))
1278+
return nfo_dic
1279+
1280+
# Read file, put it in a single-line string by removing all line endings.
1281+
nfo_str = utils_load_file_to_str(nfo_FN.getPath()).replace('\r', '').replace('\n', '')
1282+
update_dic_with_NFO_str(nfo_str, 'year', nfo_dic, 'year')
1283+
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'genre')
1284+
update_dic_with_NFO_str(nfo_str, 'developer', nfo_dic, 'developer')
1285+
update_dic_with_NFO_str(nfo_str, 'rating', nfo_dic, 'rating')
1286+
update_dic_with_NFO_str(nfo_str, 'plot', nfo_dic, 'plot')
1287+
return nfo_dic
12941288

12951289
# Returns a FileName object
12961290
def fs_get_launcher_NFO_name(settings, launcher):
@@ -1327,8 +1321,7 @@ def fs_import_category_NFO(nfo_FN, categories, categoryID):
13271321
kodi_notify_warn('NFO file not found {}'.format(os.path.basename(nfo_FN.getPath())))
13281322
log_error("fs_import_category_NFO() Not found '{}'".format(nfo_FN.getPath()))
13291323
return False
1330-
nfo_str = utils_load_file_to_str(nfo_FN.getPath())
1331-
nfo_str = nfo_str.replace('\r', '').replace('\n', '')
1324+
nfo_str = utils_load_file_to_str(nfo_FN.getPath()).replace('\r', '').replace('\n', '')
13321325
update_dic_with_NFO_str(nfo_str, 'year', nfo_dic, 'm_year')
13331326
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'm_genre')
13341327
update_dic_with_NFO_str(nfo_str, 'developer', nfo_dic, 'm_developer')
@@ -1363,15 +1356,14 @@ def fs_export_collection_NFO(nfo_FileName, collection):
13631356

13641357
# Notifies errors in Kodi GUI. Success is notified in the caller.
13651358
# Returns True if dictionary edited, False otherwise.
1366-
def fs_import_collection_NFO(nfo_FileName, collections, launcherID):
1367-
log_debug('fs_import_collection_NFO() Importing "{}"'.format(nfo_FileName.getPath()))
1368-
if not nfo_FileName.isfile():
1369-
kodi_notify_warn('NFO file not found {}'.format(os.path.basename(nfo_FileName.getOriginalPath())))
1370-
log_error("fs_import_collection_NFO() Not found '{}'".format(nfo_FileName.getPath()))
1359+
def fs_import_collection_NFO(nfo_FN, collections, launcherID):
1360+
log_debug('fs_import_collection_NFO() Importing "{}"'.format(nfo_FN.getPath()))
1361+
if not nfo_FN.isfile():
1362+
kodi_notify_warn('NFO file not found {}'.format(os.path.basename(nfo_FN.getOriginalPath())))
1363+
log_error("fs_import_collection_NFO() Not found '{}'".format(nfo_FN.getPath()))
13711364
return False
13721365

1373-
nfo_str = utils_load_file_to_str(nfo_FileName.getPath())
1374-
nfo_str = nfo_str.replace('\r', '').replace('\n', '')
1366+
nfo_str = utils_load_file_to_str(nfo_FN.getPath()).replace('\r', '').replace('\n', '')
13751367
update_dic_with_NFO_str(nfo_str, 'genre', nfo_dic, 'm_genre')
13761368
update_dic_with_NFO_str(nfo_str, 'rating', nfo_dic, 'm_rating')
13771369
update_dic_with_NFO_str(nfo_str, 'plot', nfo_dic, 'm_plot')

0 commit comments

Comments
 (0)