@@ -221,38 +221,39 @@ def _is_running(self):
221
221
def _read_info (self ) -> models .SourceInfo :
222
222
""" Read the current stream info and metadata, caching it """
223
223
try :
224
- with open (f'{ self ._get_config_folder ()} /metadata.json' , 'r' ) as file :
225
- info = json .loads (file .read ())
224
+ if not 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 ())
226
227
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
231
232
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'
235
236
236
- self ._cached_info = models .SourceInfo (** info )
237
+ self ._cached_info = models .SourceInfo (** info )
237
238
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 = ''
243
244
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
247
248
248
- return self ._cached_info
249
+ return self ._cached_info
249
250
except Exception as e :
250
251
logger .exception (f'Error reading metadata for { self .name } : { e } ' )
251
252
return models .SourceInfo (name = self .full_name (), state = 'stopped' )
252
253
253
254
def info (self ) -> models .SourceInfo :
254
255
""" Get cached stream info and source metadata """
255
-
256
+
256
257
if self ._watch_metadata :
257
258
return self ._cached_info
258
259
else :
0 commit comments