forked from rc/aircox
		
	liquidsoap: fix error in template, station.current_source on request's id
This commit is contained in:
		@ -34,17 +34,20 @@ class StationController(plugins.StationController):
 | 
			
		||||
    def fetch(self):
 | 
			
		||||
        super().fetch()
 | 
			
		||||
 | 
			
		||||
        data = self._send('request.on_air')
 | 
			
		||||
        if not data:
 | 
			
		||||
        rid = self._send('request.on_air')
 | 
			
		||||
        if not rid:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        data = self._send('request.metadata', data, parse = True)
 | 
			
		||||
        data = self._send('request.metadata', rid, parse = True)
 | 
			
		||||
        if not data:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        self.current_sound = data.get('initial_uri')
 | 
			
		||||
        # FIXME: point to the Source object
 | 
			
		||||
        self.current_source = data.get('source')
 | 
			
		||||
        self.current_source = [
 | 
			
		||||
            # we assume sound is always from a registered source
 | 
			
		||||
            source for source in self.station.get_sources()
 | 
			
		||||
            if source.rid = rid
 | 
			
		||||
        ][0]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SourceController(plugins.SourceController):
 | 
			
		||||
@ -77,10 +80,7 @@ class SourceController(plugins.SourceController):
 | 
			
		||||
        if not data:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        # FIXME: still usefull? originally tested only if there ass self.program
 | 
			
		||||
        source = data.get('source') or ''
 | 
			
		||||
        if not source.startswith(self.id):
 | 
			
		||||
            return
 | 
			
		||||
        self.rid = data.get('rid')
 | 
			
		||||
        self.current_sound = data.get('initial_uri')
 | 
			
		||||
 | 
			
		||||
    def stream(self):
 | 
			
		||||
 | 
			
		||||
@ -53,10 +53,10 @@ class StationController:
 | 
			
		||||
    """
 | 
			
		||||
    Current sound being played (retrieved by fetch)
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def id(self):
 | 
			
		||||
        return '{station.slug}_{station.pk}'.format(station = self.station)
 | 
			
		||||
    current_source = None
 | 
			
		||||
    """
 | 
			
		||||
    Current source object that is responsible of self.current_sound
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    # TODO: add function to launch external program?
 | 
			
		||||
 | 
			
		||||
@ -72,6 +72,7 @@ class StationController:
 | 
			
		||||
        """
 | 
			
		||||
        sources = self.station.get_sources()
 | 
			
		||||
        for source in sources:
 | 
			
		||||
            source.prepare()
 | 
			
		||||
            if source.controller:
 | 
			
		||||
                source.controller.fetch()
 | 
			
		||||
 | 
			
		||||
@ -110,7 +111,6 @@ class StationController:
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SourceController:
 | 
			
		||||
    """
 | 
			
		||||
    Controller of a Source. Value are usually updated directly on the
 | 
			
		||||
@ -138,10 +138,6 @@ class SourceController:
 | 
			
		||||
    Current source being responsible of the current sound
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def id(self):
 | 
			
		||||
        return '{source.station.slug}_{source.slug}'.format(source = self.source)
 | 
			
		||||
 | 
			
		||||
    __playlist = None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user