Improve playlist file opening check
This commit is contained in:
@@ -27,8 +27,7 @@ from time import time
|
||||
from src import shared
|
||||
from src.game import Game
|
||||
from src.importer.sources.location import Location
|
||||
from src.importer.sources.source import (Source, SourceIterationResult,
|
||||
SourceIterator)
|
||||
from src.importer.sources.source import Source, SourceIterationResult, SourceIterator
|
||||
|
||||
|
||||
class RetroarchSourceIterator(SourceIterator):
|
||||
@@ -40,13 +39,13 @@ class RetroarchSourceIterator(SourceIterator):
|
||||
if file.endswith(".lpl"):
|
||||
playlist_files.append(file)
|
||||
|
||||
playlist_items = []
|
||||
for playlist_file in playlist_files:
|
||||
open_file = open(
|
||||
str(self.source.config_location["playlists"]) + "/" + playlist_file
|
||||
)
|
||||
try:
|
||||
playlist_json = json.load(open_file)
|
||||
with open(
|
||||
self.source.config_location["playlists"] / playlist_file,
|
||||
encoding="utf-8",
|
||||
) as open_file:
|
||||
playlist_json = json.load(open_file)
|
||||
except (JSONDecodeError, OSError, KeyError):
|
||||
logging.warning("Cannot read playlist file: %s", str(playlist_file))
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user