@@ -18,7 +18,7 @@ class FMRadio(BaseStream):
1818 def __init__ (self , name : str , freq , logo : Optional [str ] = None , disabled : bool = False , mock : bool = False ):
1919 super ().__init__ (self .stream_type , name , disabled = disabled , mock = mock )
2020 self .freq = freq
21- self .default_image_url = logo
21+ self .logo = logo
2222 self .stopped_message = None
2323
2424 def reconfig (self , ** kwargs ):
@@ -39,8 +39,8 @@ def reconfig(self, **kwargs):
3939 def connect (self , src ):
4040 """ Connect a fmradio.py output to a given audio source """
4141
42+ self ._connect (src )
4243 if self .mock :
43- self ._connect (src )
4444 return
4545
4646 song_info_path = f'{ self ._get_config_folder ()} /metadata.json'
@@ -62,48 +62,18 @@ def _is_running(self):
6262
6363 def disconnect (self ):
6464 if self ._is_running ():
65- os . killpg ( os . getpgid ( self .proc . pid ), signal . SIGKILL )
65+ utils . careful_proc_shutdown ( self .proc )
6666 self .proc = None
6767 self ._disconnect ()
6868
69- # def info(self) -> models.SourceInfo:
70- # src_config_folder = f"{utils.get_folder('config')}/srcs/{self.src}"
71- # loc = f'{src_config_folder}/currentSong'
72- # if not self.logo:
73- # self.logo = "static/imgs/fmradio.png"
74- # source = models.SourceInfo(
75- # name=self.full_name(),
76- # state=self.state,
77- # img_url=self.logo,
78- # type=self.stream_type
79- # )
80- # try:
81- # with open(loc, 'r', encoding='utf-8') as file:
82- # data = json.loads(file.read())
83- # # Example JSON: "station": "Mixx96.1", "callsign": "KXXO", "prog_type": "Soft rock", "radiotext": " x96.1"
84- # # logger.debug(json.dumps(data))
85- # if data['prog_type']:
86- # source.artist = data['prog_type']
87- # else:
88- # source.artist = self.freq + " FM"
89-
90- # if data['radiotext']:
91- # source.track = data['radiotext']
92- # else:
93- # source.track = self.name
94-
95- # if data['station']:
96- # source.station = data['station']
97- # elif data['callsign']:
98- # source.station = data['callsign']
99- # else:
100- # source.station = ""
101-
102- # return source
103- # except Exception:
104- # pass
105- # # logger.exception('Failed to get currentSong - it may not exist: {}'.format(e))
106- # return source
69+ def _read_info (self ) -> models .SourceInfo :
70+ # we have to override this method because we need to set the img_url
71+ super ()._read_info ()
72+ if self .logo :
73+ self ._cached_info .img_url = self .logo
74+ else :
75+ self ._cached_info .img_url = 'static/imgs/internet_radio.png'
76+ return self ._cached_info
10777
10878 @staticmethod
10979 def is_hw_available ():
0 commit comments