@@ -221,38 +221,39 @@ def _is_running(self):
221221 def _read_info (self ) -> models .SourceInfo :
222222 """ Read the current stream info and metadata, caching it """
223223 try :
224- with open (f'{ self ._get_config_folder ()} /metadata.json' , 'r' ) as file :
225- info = json .loads (file .read ())
224+ if os .path .exists (f'{ self ._get_config_folder ()} /metadata.json' ):
225+ with open (f'{ self ._get_config_folder ()} /metadata.json' , 'r' ) as file :
226+ info = json .loads (file .read ())
226227
227- # populate fields that are type-consistent
228- info ['name' ] = self .full_name ()
229- info ['type' ] = self .stype
230- info ['supported_cmds' ] = self .supported_cmds
228+ # populate fields that are type-consistent
229+ info ['name' ] = self .full_name ()
230+ info ['type' ] = self .stype
231+ info ['supported_cmds' ] = self .supported_cmds
231232
232- # set state to stopped if it is not present in the metadata (e.g. on startup)
233- if 'state' not in info :
234- info ['state' ] = 'stopped'
233+ # set state to stopped if it is not present in the metadata (e.g. on startup)
234+ if 'state' not in info :
235+ info ['state' ] = 'stopped'
235236
236- self ._cached_info = models .SourceInfo (** info )
237+ self ._cached_info = models .SourceInfo (** info )
237238
238- # set stopped message if stream is stopped
239- if self .stopped_message and self ._cached_info .state == 'stopped' :
240- self ._cached_info .artist = self .stopped_message
241- self ._cached_info .track = ''
242- self ._cached_info .album = ''
239+ # set stopped message if stream is stopped
240+ if self .stopped_message and self ._cached_info .state == 'stopped' :
241+ self ._cached_info .artist = self .stopped_message
242+ self ._cached_info .track = ''
243+ self ._cached_info .album = ''
243244
244- # set default image if none is provided
245- if not self ._cached_info .img_url :
246- self ._cached_info .img_url = self .default_image_url
245+ # set default image if none is provided
246+ if not self ._cached_info .img_url :
247+ self ._cached_info .img_url = self .default_image_url
247248
248- return self ._cached_info
249+ return self ._cached_info
249250 except Exception as e :
250251 logger .exception (f'Error reading metadata for { self .name } : { e } ' )
251252 return models .SourceInfo (name = self .full_name (), state = 'stopped' )
252253
253254 def info (self ) -> models .SourceInfo :
254255 """ Get cached stream info and source metadata """
255-
256+
256257 if self ._watch_metadata :
257258 return self ._cached_info
258259 else :
0 commit comments