Is it possible to muxes or channels through command line or the API?
Directly add muxes/channels without the web interface
DeltaMikeCharlie Thanks. Is it possible to create channels directly without adding muxes and services first?
Mehdi Is it possible to create channels directly without adding muxes and services first?
I'm not sure. Normally, a channel needs to be linked to 1 or more services. Perhaps you could create a channel object will a null service UUID, but it would be useless.
DeltaMikeCharlie Sorry for asking a dumb question but... I just looked at the channel link you gave and I see for example
channel/create
Creates a new channel. Requires ADMIN privilege.
conf A JSON object containing details of the new channel.
but there are no links in that listing. Where would I find the description of a 'conf' object for example, or any of the others that are mentioned. I've had a quick browse but didn't see anything.
DaveH Where would I find the description of a 'conf' object for example
I don't have that exact information to hand at the moment, but try to get a channel list and then look at an individual channel object. That should give you a good place to start in creating the conf
object that you need.
DaveH Where would I find the description of a 'conf' object for example
Here is a hacked-together example of some python code. It won't work as is, but it should give lots of hints.
Have a look at how the newChannel
object is created and then in __createOBJ
how newObject
is created and then added to the URL.
newChannel = {}
newChannel['class'] = "channel"
newChannel['conf'] = {}
newChannel['conf']['enabled'] = True
newChannel['conf']['autoname'] = True
newChannel['conf']['name'] = service['svcname']
newChannel['conf']['number'] = service['lcn']
newChannel['conf']['services'] = []
newChannel['conf']['services'].append(service['uuid'])
newChannel['conf']['tags'] = []
if len(tagUUID) != 0:
newChannel['conf']['tags'].append(tagUUID)
ret = self.__createOBJ("channel/create", newChannel)
#Create a TVH Object
def __createOBJ(self, url, payload):
tvhResponse = ""
newObject = "class=" + payload['class'] + "&conf=" + json.dumps(payload['conf'], separators=(',', ':'))
newObject = newObject.replace(" ", "%20")
json_url = "http://" + self.__hostName + ":" + str(self.__httpPort) + "/api/" + url + "?" + newObject
req = request.Request(json_url, method="GET")
req.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
r = request.urlopen(req)
tvhResponse = r.read()
jRet = json.loads(tvhResponse)
uu = ""
if 'uuid' in jRet:
uu = jRet['uuid']
else:
uu = str(tvhResponse)
extra = ""
if 'name' in payload['conf']:
extra = " name = '" + payload['conf']['name'] + "'"
if 'networkname' in payload['conf']:
extra = " networkname = '" + payload['conf']['networkname'] + "'"
if 'display_label' in payload['conf']:
extra = " display_label = '" + payload['conf']['display_label'] + "'"
self.__logger("Created object, class '" + payload['class'] + "' uuid = '" + uu + "'" + extra)
return tvhResponse