Da kann ich helfen.
Im Anhang ein Auszug aus meinem Icast2 Meata-Update:
Code:
# Icecast Meta-Update
import urllib2
icecastrun = process_num("icecast2")
ezstreamrun = process_num("ezstream")
if int(icecastrun) > 0 and int(ezstreamrun) > 0:
print "Icecast und ezstream laufen"
metadata = str(datum) + " " + str(zeit) + " [" + str(schleife) + "] " + str(org) + " " + str(ort) + " " + str(bez)
metadata = metadata.replace(" ","+") #add "+" instead of " " for icecast2
url = "http://" + str(icecast_server) + ":" + str(icecast_port) + "/admin/metadata?mount=/" + str(icecast_mountpoint) + "&mode=updinfo&charset=UTF-8&song=" + str(metadata)
# simple wrapper function to encode the username & pass
def encodeUserData(user, password):
return "Basic " + (user + ":" + password).encode("base64").rstrip()
# create the request object and set some headers
req = urllib2.Request(url)
req.add_header('Accept', 'application/json')
req.add_header("Content-type", "application/x-www-form-urlencoded")
req.add_header('Authorization', encodeUserData(icecast_user, icecast_password))
# make the request and print the results
res = urllib2.urlopen(req)
print res.read()
else:
print "Icecast oder/und ezstream laufen nicht"
Gruß
Marcel