Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 8 of 8
  1. #1

    Werbung bei Internet Radio ausblenden

    Ich höre oft den Sender "GotRadio Alternative Rock". Der blendet als Song Title "Advertisment" ein, sobald Werbung kommt. An Hand dieses Titles ist also einfach zu erkennen, ob Werbung kommt oder nicht.

    Man muss nicht alles selber machen. Daher:

    Gibt es bereits ein PlugIn oder einen CLI-Skript, der so etwas auswertet (gerne auch für andere Sender und Erkennungsmethoden) und dann z.B. die Lautstärke auf 0 dimmt und am Ende wieder restauriert?

  2. #2
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    652
    Quote Originally Posted by Squeezy View Post
    Ich höre oft den Sender "GotRadio Alternative Rock". Der blendet als Song Title "Advertisment" ein, sobald Werbung kommt. An Hand dieses Titles ist also einfach zu erkennen, ob Werbung kommt oder nicht.

    Man muss nicht alles selber machen. Daher:

    Gibt es bereits ein PlugIn oder einen CLI-Skript, der so etwas auswertet (gerne auch für andere Sender und Erkennungsmethoden) und dann z.B. die Lautstärke auf 0 dimmt und am Ende wieder restauriert?
    Code:
    #!/bin/bash
    
    which nc6 &>/dev/null || { echo "no netcat6 found"; exit 1; }
    
    LMS=lmsserver
    TRIGGER="Advertisment " 
    DEBUG=
    
    declare -A plStat
    declare -A plMute
    
    while true; do 
    	psAR=( `echo "players 0 99"|nc6 -q1 $LMS 9090  2>/dev/null` )
    	for i in "${psAR[@]}"; do
    		if [[ $i == "playerid"* ]]; then
    			PLID=${i/playerid%3A/}
    		fi
    		if [[ $i == "connected%3A"* ]]; then
    			CS=${i/connected%3A/}
    			[ $DEBUG ] && echo "P: $PLID CS: $CS"
    
    			if [ $CS -eq 1 ]; then
    				CSONG="`echo "$PLID current_title ?"|nc6 -q1 $LMS 9090  2>/dev/null|sed -e "s/$PLID current_title //"` "
    				[ $DEBUG ] && echo -n "P: [$PLID] CSONG: [$CSONG] (old: [${plStat[$PLID]}] ): "
    				if [ -n "${plStat[$PLID]}" ] && [ "${plStat[$PLID]}" == "$CSONG" ]; then
    					[ $DEBUG ] && echo "unchanged"
    				else
    					[ $DEBUG ] && echo "changed"
    					if [[ $CSONG == "$TRIGGER" ]]; then
    						[ $DEBUG ] && echo "match trigger -> mute"
    						plMute["$PLID"]=1;
    						echo "$PLID mixer muting"|nc6 --send-only $LMS 9090 &>/dev/null
    					else
    						if [ -n "${plMute[$PLID]}" ] && [ "${plMute[$PLID]}" -eq "1" ]; then
    							VOL=`echo "$PLID mixer volume ?"|nc6 -q1 $LMS 9090  2>/dev/null|sed -e "s/$PLID mixer volume //"`
    							[ $DEBUG ] && echo "mute on -> unmute (vol=$VOL)"
    							plMute["$PLID"]=0;
    							echo "$PLID mixer muting"|nc6 --send-only $LMS 9090 &>/dev/null
    							echo "$PLID mixer volume $VOL"|nc6 --send-only $LMS 9090 &>/dev/null
    						fi
    					fi
    				fi
    				plStat["$PLID"]=$CSONG;
    			fi
    
    		fi
    	done
    	sleep 2
    done
    - LMS und TRIGGER anpassen
    - benötigt netcat6

  3. #3
    Senior Member
    Join Date
    May 2017
    Posts
    203
    Eh, is this a solution?
    SqueezeBoxes: 2x SB2 (Living room and study), 1x Radio (Kitchen), 1x Boom (Dining room), 1x piCorePlayer (jacuzzi), 1x piCorePlayer (Garden) 1x OSMC + Squeezelite (Movie room), 1x Touch (Bedroom)
    Server: LMS on Pi3 7.9.1. on PcP 3.21
    Network: AVM Fritzbox, D-Link Smart Switch 24p, 3x Ubiquity

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,781

    Werbung bei Internet Radio ausblenden

    > Eh, is this a solution?

    Alle Wege führen nach Rom... scheint eine mögliche Lösung zu sein. Ein
    Plugin wäre wohl etwas einfacher zu installieren...

    Eigentlich wäre so ein Plugin, welches bei gewissen Stichworten auf
    Stumm schaltet, ganz cool. Ich denke da nicht nur an Werbung.
    "Despacito" und andere Schlüsselwörter wären da auch denkbar :-). Oh,
    wenn ich etwas mehr Freizeit hätte...

    --

    Michael
    --

    Michael

  5. #5
    Senior Member
    Join Date
    Jan 2013
    Posts
    215
    +1 for the plugin

    ok for supporting the radios but some of the announces are very annoying.

    I had started a suggestion thread for similar:
    http://forums.slimdevices.com/showth...ist&highlight=
    Last edited by mkkyah; 2017-08-20 at 04:54.

  6. #6
    Senior Member bluetdi's Avatar
    Join Date
    Oct 2008
    Location
    Vienna
    Posts
    231
    +1
    Wie können wir Michael mehr Freizeit verschaffen? Abwasch machen, Kinder bespaßen, Heimarbeitsplatz beantragen....
    Odroid U3+m2p+LMS | Pi3-7"+pCP+LMS | Transporter | 2x Touch | 2x Classic | 2x Boom | 2x Radio | iPeng

  7. #7
    Banned
    Join Date
    Sep 2017
    Posts
    1
    Danke für Plugin! Der funktioniert wie es echt soll

  8. #8

    Java Implementierung

    Zunächst mal vielen Dank an Roland0. Habe mir Deine Implementierung angeschaut, habe mich dann doch entschieden, was eigenes in Java zu machen.

    Damit auch andere was davon haben, hier eine Kopie davon.

    Das Ganze macht dann aber noch etwas mehr. Schaltet Lautsprecher/Verstärker ein/aus, je nachdem, ob von Squeezebox benötigt. Müsst Ihr halt ausbauen, wenn nicht benötigt (einfach Einträge aus config properties raus) oder anpassen, je nachdem was für eine Steuerung Ihr dafür habt.

    Die Schlüssel zur Erkennung, ob Werbung läuft, müsst Ihr dann auch noch an Eure Sender anpassen. Sie sind im String[] ads in SqueezeboxCLIListener definiert. Ich einen Sender der tatsächlich "silence" einblendet, wenn Werbung kommt.

    Viel Erfolg

    Squeezy

    ==============


    config.properties
    Code:
    SB_WOHNEN	=00:04:20:07:d3:a8
    SB_GALERIE	=00:04:20:07:d3:0f
    SB_PI		=74:da:38:54:29:a6
    SB_BAD		=00:04:20:06:4d:cb
    
    SB_SERVER	=zeus.whitehouse.lan
    SB_CLI_PORT	=9090
    
    SB_WOHNEN_SPEAKER	=http://zeus.whitehouse.lan:8080/WhitehouseControl/pages/control1BitDpt1.jsp?adr=1/2/3&value=%1&return=controlRooms.jsp
    SB_GALERIE_SPEAKER	=http://zeus.whitehouse.lan:8080/WhitehouseControl/pages/control1BitDpt1.jsp?adr=1/2/8&value=%1&return=controlRooms.jsp
    SB_PI_SPEAKER		=http://zeus.whitehouse.lan:8080/WhitehouseControl/pages/control1BitDpt1.jsp?adr=1/2/8&value=%1&return=controlRooms.jsp
    Player.java
    Code:
    import java.util.Properties;
    
    
    public class Player {
    	
    	String name = "- unset -";
    	String mac;
    	SqueezeboxCLIListener cli;
    	String speakerOnURL;
    	String speakerOffURL;
    	
    	private boolean adPlaying = false;
    	
    	public Player(String _name, Properties config, SqueezeboxCLIListener _cli) {
    		
    		name=_name;
    		mac=config.getProperty(name);
    		cli=_cli;
    		
    		String speakerControl = config.getProperty(name+"_SPEAKER");
    		if (speakerControl != null) {
    			speakerOnURL = speakerControl.replace("%1", "On"); 
    			speakerOffURL = speakerControl.replace("%1", "Off"); 
    		}
    		
    		cli.players.put(mac.hashCode(), this);
    		
    	}
    	
    	
    	public void setAdPlaying(boolean _adPlaying) {
    
    		if(adPlaying != _adPlaying) { //something changed
    			adPlaying = _adPlaying;
    			if (adPlaying) {
    				cli.logger.info("Ad has started now");
    				cli.setMuting(this,1);
    			}
    			else {
    				cli.logger.info("Ad has ended now");
    				cli.setMuting(this,0);
    			}
    		}
    	}
    
    
    	public void powerOn() {
    		if(speakerOnURL != null) 
    			cli.doHttpCommand(speakerOnURL);
    	}
    
    
    	public void powerOff() {
    		if(speakerOffURL != null) 
    			cli.doHttpCommand(speakerOffURL);
    	}
    
    	public String toString() {
    		return name;
    	}
    
    
    	public boolean isAdplaying() {
    		return adPlaying;
    	}
    	
    }
    SqueezeboxCLIListener.java
    Code:
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintStream;
    import java.net.URL;
    import java.util.Hashtable;
    import java.util.Iterator;
    import java.util.Properties;
    
    import org.apache.commons.net.telnet.TelnetClient;
    import org.apache.log4j.Logger;
    import org.apache.log4j.PropertyConfigurator;
    
    
    
    public class SqueezeboxCLIListener {
    
    	private static final String[] speaker_on = {
    		"power 1",
    		"button play",
    		"playlist play",
    		"play "
    	};
    	
    	private static final String[] speaker_off = {
    		"power 0"
    	};
    	
    	private static final String[] ads = {
    		"playlist newsong Live365%20-%20Advertisement",
    		"playlist newsong 90s%20Alt%20_Get%2090s",
    		"playlist newsong Silence"
    	};
    	
    	private static final String[] end_ads = {
    		"playlist newsong",
    	};
    	
    	protected static Hashtable<Integer, Player> players = new Hashtable<Integer, Player>();
    	
    	private TelnetClient telnet = new TelnetClient();
    	private InputStream in;
    	private PrintStream out;
    
    	/**
    	 * The default logger for messages and errors
    	 */
    	protected Logger logger;
    
    	StringBuffer sb = new StringBuffer();
    
    	public SqueezeboxCLIListener() throws IOException {
    
    		logger = Logger.getLogger(getClass());
    		Properties log4JProperties = new Properties();
    		try {
    			log4JProperties.load(
    					ClassLoader.getSystemResourceAsStream("log4j.properties"));
    			PropertyConfigurator.configure(log4JProperties);
    		} catch (IOException e) {
    			System.err.println("log4j.properties not found or not configured correctly. Read the log4j manual if you need help.");
    			throw e;
    		}
    		
    		logger.info("Version 2017-10-08 started");
    		
    		Properties config = new Properties();
    		try {
    			config.load(
    					ClassLoader.getSystemResourceAsStream("config.properties"));
    			
    		} catch (IOException e) {
    			System.err.println("config.properties not found or not configured correctly.");
    			throw e;
    		}
    		
    		new Player("SB_WOHNEN",config,this);
    		new Player("SB_GALERIE",config,this);
    		new Player("SB_PI",config,this);
    		new Player("SB_BAD",config,this);
    		
    		while(true) {	//loop forever	
    			try {
    				// Connect to the specified server
    				telnet.connect(config.getProperty("SB_SERVER"), new Integer(config.getProperty("SB_CLI_PORT")));
    
    				// Get input and output stream references
    				in = telnet.getInputStream();
    				out = new PrintStream(telnet.getOutputStream());
    				sb.append("Read -> ");
    
    				write("listen 1");
    				read();
    			}
    			catch (Exception e) {
    				try {
    					Thread.sleep(30000);   //wait 30 secs before reconnect
    				} catch (InterruptedException e1) {
    				} 
    			}
    		}
    	}
    
    	public String read() throws IOException {
    		char ch = (char) in.read();
    		while (true) {
    
    			if (ch=='\n') {
    				interpretCommand();
    			} else
    			{
    				if (ch!='\r')
    					sb.append(ch);
    				if ((int)ch > 65000) {
    					logger.fatal("Squeezeboxserver is dead, try to reconnect.");
    					throw new IOException();
    				}
    			}
    
    			ch = (char) in.read();
    		}
    	}
    
    	/**
    	 * @param sb
    	 */
    	protected void interpretCommand() {
    		String line = sb.toString().replaceAll("%3A", ":");
    		
    		if (line.contains("listen"))
    			logger.info(line);
    		else
    			logger.debug(line);
    		
    		String _player = line.split(" ")[2];
    		Player player = players.get(_player.hashCode()); 
    		
    		testLineForSpeakerOn(player, line);
    		testLineForSpeakerOff(player, line);
    		testLineForAds(player, line);
    		testLineForEndAds(player, line);
    		
    		sb.setLength(0);
    		sb.append("Read -> ");
    	}
    
    	private void testLineForSpeakerOn(Player player, String line) {
    		if (testLineFor(speaker_on, line)) {
    			logger.info("Speaker on for player: " + player);
    			player.powerOn();
    		}
    	}
    
    	private void testLineForSpeakerOff(Player player, String line) {
    		if (testLineFor(speaker_off, line)) {
    			logger.info("Speaker off for player: " + player);
    			player.powerOff();
    		}
    	}
    
    	private void testLineForAds(Player player, String line) {
    		if (testLineFor(ads, line)) {
    			logger.info("Ad detected for player: " + player);
    			player.setAdPlaying(true);
    		}
    	}
    
    	private void testLineForEndAds(Player player, String line) {
    		if (testLineFor(ads, line)) return; 
    		if (testLineFor(end_ads, line)) 
    		{
    			logger.info("Something different than ad detected for player: " + player);
    			player.setAdPlaying(false);
    		}
    	}
    
    	protected boolean testLineFor(String[] keys, String line) {
    		ArrayIterator ai = new ArrayIterator(keys);
    		while(ai.hasNext()) {
    			String test = (String)ai.next();
    			if (line.contains(test)) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    	protected void doHttpCommand(String cmd) {
    		URL url;
    		try {
    			url = new URL(cmd);
    			InputStream is;
    			is = url.openStream();
    			is.close();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    
    	public void write(String value) {
    		try {
    			out.println(value);
    			out.flush();
    			logger.info("Write-> "+value);
    		}
    		catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	public void disconnect() {
    		try {
    			telnet.disconnect();
    		}
    		catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	public static void main(String[] args) {
    		try {
    			SqueezeboxCLIListener telnet = new SqueezeboxCLIListener();
    			telnet.disconnect();
    		}
    		catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	public void setMuting(Player player, int mute) {
    		write(player.mac + " mixer muting " + mute);
    		
    	}
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •