@@ -365,21 +365,27 @@ def _retrieveThumbnailPath(self, filepath: str) -> str:
365365 Returns:
366366 The path to the thumbnail if it could be found, an empty string otherwise
367367 """
368- thumbnail = ""
369368 try :
370369 with open (filepath ) as file :
371370 fileData = json .load (file )
372- # Find the first CameraInit node
373- fileData = fileData ["graph" ]
374- for node in fileData :
375- if fileData [node ]["nodeType" ] == "CameraInit" and fileData [node ]["inputs" ].get ("viewpoints" ):
376- if len (fileData [node ]["inputs" ]["viewpoints" ]) > 0 :
377- thumbnail = fileData [node ]["inputs" ]["viewpoints" ][0 ]["path" ]
378- break
379- except FileNotFoundError :
380- pass
381371
382- return thumbnail
372+ graphData = fileData .get ("graph" , {})
373+ for node in graphData .values ():
374+ if node .get ("nodeType" ) != "CameraInit" :
375+ continue
376+ if viewpoints := node .get ("inputs" , {}).get ("viewpoints" ):
377+ return viewpoints [0 ].get ("path" , "" )
378+
379+ except FileNotFoundError :
380+ logging .info ("File {} not found on disk." .format (filepath ))
381+ except (json .JSONDecodeError , UnicodeDecodeError ):
382+ logging .info ("Error while loading file {}." .format (filepath ))
383+ except KeyError as err :
384+ logging .info ("The following key does not exist: {}" .format (str (err )))
385+ except Exception as err :
386+ logging .info ("Exception: {}" .format (str (err )))
387+
388+ return ""
383389
384390 def _getRecentProjectFilesFromSettings (self ) -> list [dict [str , str ]]:
385391 """
0 commit comments