cleanup redundant code, remove whitespace
This commit is contained in:
parent
d1a22fe7ca
commit
2010778876
|
@ -254,29 +254,15 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
||||||
if user == "" then
|
if user == "" then
|
||||||
user_ref := "source"
|
user_ref := "source"
|
||||||
end
|
end
|
||||||
|
|
||||||
description_ref = ref description
|
|
||||||
if description == "" then
|
|
||||||
description_ref := "N/A"
|
|
||||||
end
|
|
||||||
|
|
||||||
genre_ref = ref genre
|
|
||||||
if genre == "" then
|
|
||||||
genre_ref := "N/A"
|
|
||||||
end
|
|
||||||
|
|
||||||
url_ref = ref url
|
|
||||||
if url == "" then
|
|
||||||
url_ref := "N/A"
|
|
||||||
end
|
|
||||||
output.shoutcast_mono = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
output.shoutcast_mono = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||||
host = host,
|
host = host,
|
||||||
port = port,
|
port = port,
|
||||||
password = pass,
|
password = pass,
|
||||||
fallible = true,
|
fallible = true,
|
||||||
url = !url_ref,
|
url = url,
|
||||||
genre = !genre_ref,
|
genre = genre,
|
||||||
name = !description_ref,
|
name = description,
|
||||||
user = !user_ref,
|
user = !user_ref,
|
||||||
on_error = on_error,
|
on_error = on_error,
|
||||||
on_connect = on_connect)
|
on_connect = on_connect)
|
||||||
|
@ -286,9 +272,9 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
||||||
port = port,
|
port = port,
|
||||||
password = pass,
|
password = pass,
|
||||||
fallible = true,
|
fallible = true,
|
||||||
url = !url_ref,
|
url = url,
|
||||||
genre = !genre_ref,
|
genre = genre,
|
||||||
name = !description_ref,
|
name = description,
|
||||||
user = !user_ref,
|
user = !user_ref,
|
||||||
on_error = on_error,
|
on_error = on_error,
|
||||||
on_connect = on_connect)
|
on_connect = on_connect)
|
||||||
|
|
|
@ -27,14 +27,14 @@ def printUsage():
|
||||||
print " -m mount (default: test) "
|
print " -m mount (default: test) "
|
||||||
print " -h show help menu"
|
print " -h show help menu"
|
||||||
|
|
||||||
|
|
||||||
def find_liquidsoap_binary():
|
def find_liquidsoap_binary():
|
||||||
"""
|
"""
|
||||||
Starting with Airtime 2.0, we don't know the exact location of the Liquidsoap
|
Starting with Airtime 2.0, we don't know the exact location of the Liquidsoap
|
||||||
binary because it may have been installed through a debian package. Let's find
|
binary because it may have been installed through a debian package. Let's find
|
||||||
the location of this binary.
|
the location of this binary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
rv = subprocess.call("which airtime-liquidsoap > /dev/null", shell=True)
|
rv = subprocess.call("which airtime-liquidsoap > /dev/null", shell=True)
|
||||||
if rv == 0:
|
if rv == 0:
|
||||||
return "airtime-liquidsoap"
|
return "airtime-liquidsoap"
|
||||||
|
@ -78,7 +78,7 @@ for o, a in optlist:
|
||||||
mount = a
|
mount = a
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
print "Protocol: %s " % stream_type
|
print "Protocol: %s " % stream_type
|
||||||
print "Host: %s" % host
|
print "Host: %s" % host
|
||||||
print "Port: %s" % port
|
print "Port: %s" % port
|
||||||
|
@ -86,35 +86,35 @@ try:
|
||||||
print "Password: %s" % password
|
print "Password: %s" % password
|
||||||
if stream_type == "icecast":
|
if stream_type == "icecast":
|
||||||
print "Mount: %s\n" % mount
|
print "Mount: %s\n" % mount
|
||||||
|
|
||||||
url = "http://%s:%s/%s" % (host, port, mount)
|
url = "http://%s:%s/%s" % (host, port, mount)
|
||||||
print "Outputting to %s streaming server. You should be able to hear a monotonous tone on '%s'. Press ctrl-c to quit." % (stream_type, url)
|
print "Outputting to %s streaming server. You should be able to hear a monotonous tone on '%s'. Press ctrl-c to quit." % (stream_type, url)
|
||||||
|
|
||||||
liquidsoap_exe = find_liquidsoap_binary()
|
liquidsoap_exe = find_liquidsoap_binary()
|
||||||
|
|
||||||
if liquidsoap_exe is None:
|
if liquidsoap_exe is None:
|
||||||
raise Exception("Liquidsoap not found!")
|
raise Exception("Liquidsoap not found!")
|
||||||
|
|
||||||
if stream_type == "icecast":
|
if stream_type == "icecast":
|
||||||
command = "%s 'output.icecast(%%vorbis, host = \"%s\", port = %s, user= \"%s\", password = \"%s\", mount=\"%s\", sine())'" % (liquidsoap_exe, host, port, user, password, mount)
|
command = "%s 'output.icecast(%%vorbis, host = \"%s\", port = %s, user= \"%s\", password = \"%s\", mount=\"%s\", sine())'" % (liquidsoap_exe, host, port, user, password, mount)
|
||||||
else:
|
else:
|
||||||
command = "%s /usr/lib/airtime/pypo/bin/liquidsoap_scripts/library/pervasives.liq 'output.shoutcast(%%mp3, host=\"%s\", port = %s, user= \"%s\", password = \"%s\", sine())'" \
|
command = "%s /usr/lib/airtime/pypo/bin/liquidsoap_scripts/library/pervasives.liq 'output.shoutcast(%%mp3, host=\"%s\", port = %s, user= \"%s\", password = \"%s\", sine())'" \
|
||||||
% (liquidsoap_exe, host, port, user, password)
|
% (liquidsoap_exe, host, port, user, password)
|
||||||
|
|
||||||
if not verbose:
|
if not verbose:
|
||||||
command += " 2>/dev/null | grep \"failed\""
|
command += " 2>/dev/null | grep \"failed\""
|
||||||
else:
|
else:
|
||||||
print command
|
print command
|
||||||
|
|
||||||
#print command
|
#print command
|
||||||
rv = subprocess.call(command, shell=True)
|
rv = subprocess.call(command, shell=True)
|
||||||
|
|
||||||
#if we reach this point, it means that our subprocess exited without the user
|
#if we reach this point, it means that our subprocess exited without the user
|
||||||
#doing a keyboard interrupt. This means there was a problem outputting to the
|
#doing a keyboard interrupt. This means there was a problem outputting to the
|
||||||
#stream server. Print appropriate message.
|
#stream server. Print appropriate message.
|
||||||
print "There was an error with your stream configuration. Please review your configuration " + \
|
print "There was an error with your stream configuration. Please review your configuration " + \
|
||||||
"and run this program again. Use the -h option for help"
|
"and run this program again. Use the -h option for help"
|
||||||
|
|
||||||
except KeyboardInterrupt, ki:
|
except KeyboardInterrupt, ki:
|
||||||
print "\nExiting"
|
print "\nExiting"
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
Loading…
Reference in New Issue