Yusef, I'm going to try to walk you through this, but I can't guarantee everything will come through as intended.
Yusef Neblett wrote:
> I run the cablecard.sh script:
>
> root@raspberrypi:/media/tvhd# bash -x cablecard.sh
> +
TVHEADEND=TVHEADENDMIGRATIONSTART148b50d6b4674200b4af17af7c15d711TVHEADENDMIGRATIONEND
> + NETWORK=CCPrime
> +
DEVICE=1323B3C0
> ++ curl -sS TVHEADENDMIGRATIONSTART6c10bf857ed34b9b8ea54ab8e729e7c9TVHEADENDMIGRATIONEND -d class=dvbnetwork_cablecard -d 'enum = 1'
> ++ tr -d '"'
> ++ jq '.entries[] | select(.val == "CCPrime") | .key'
> parse error: Invalid numeric literal at line 1, column 10
> +
UUID=
> ++ curl -sS TVHEADENDMIGRATIONSTART57a572eb8eb9497ba266ae296f7863a7TVHEADENDMIGRATIONEND
> ++ jq '.[] | select(.DeviceID == "1323B3C0") | .LineupURL'
> ++ tr -d '"'
> + LINEUP=
http://192.168.1.100:80/lineup.json
> ++ curl -sS
http://192.168.1.100:80/lineup.json
> ++ jq '.[].GuideNumber | tonumber'
> + for
CHANNEL in $(
> curl -sS "${LINEUP}" |
> jq '.[].GuideNumber | tonumber')
> + curl -sS
http://admin:mypass@127.0.0.1:9981/api/mpegts/network/mux_create -d uuid= --data-urlencode 'conf={"epg":0, "vchan":11}'
> + for
CHANNEL in $(
> curl -sS "${LINEUP}" |
> jq '.[].GuideNumber | tonumber')
A couple things to begin with:
# I'm not sure if it is merely a formatting issue with you cutting-and-pasting your terminal's output, or some other error you made when you saved the script, but I'm not sure I fully understand what you've posted. The series of
+
and
++
make no sense, and there are missing elements that render what you have posted unworkable.
# When you run the script, if you have saved it as a file called
cablecard.sh@, all that you need to do to execute it is call the script; if you are executing the script from the same directory in which it is saved, you would merely type @./cablecard.sh
. Telling
bash
to execute the script may cause issues, as this is not a
bash
script, but rather POSIX shell.
With that said,
curl
can sometimes have problems escaping input, which is why in my example script the
_TVHEADEND
variable is double-quoted when it is defined. Also, it is not clear if the output you are sharing is the result of running the script as a script, or whether from your attempts at troubleshooting by manually entering the commands. If you are troubleshooting (and manually entering the commands), either set the variables in your shell or just substitute the actual text.
I'm going to walk through the script step-by-step.
#!/bin/sh
_TVHEADEND="http://localhost:9981" # URL used to access Tvheadend WebUI
_NETWORK=Cable # Name of CableCARD network to add muxes to
_DEVICE=FFFFFFFF # DeviceID of HDHomeRun device
If you were running this as a script, you would modify these variables to suit your needs. In my case, I do not need a username or password for admin access to my Tvheadend server based upon the access controls that I have established. To differentiate my CableCARD network from any others, I've named it after my cable provider. Also, I have several HDHR Primes, but I only need one with a channel lineup. So, here are the variables I use for my script:
_TVHEADEND="http://10.0.0.21:9981"
_NETWORK=Charter
_DEVICE=1321F1A1
Now, if instead of running this as a script, but you were going to manually run the commands to make sure everything works, you could do so by setting the variables in your terminal with commands such as:
export _TVHEADEND="http://10.0.0.21:9981"@, @export _NETWORK=Charter@, and @export _DEVICE=1321F1A1@.
The next part of the script sets a variable called @_UUID
to the UUID that Tvheadend assigned to your CableCARD network when you created it.
_UUID=$(
curl -sS "${_TVHEADEND}/api/idnode/load" \
-d "class=dvb_network_cablecard" -d "enum=1" |
jq ".entries[] | select(.val == \"${_NETWORK}\") | .key" |
tr -d \")
This is actually doing several things:
# Run the command
curl -sS "${_TVHEADEND}/api/idnode/load" -d "class=dvb_network_cablecard" -d "enum=1"
(This command asks the Tvheadend server for the names and UUIDs of all of the CableCARD networks)
# Take the ouput from the previous
curl
command, and use it as the input into the command
jq ".entries[] | select(.val == \"${_NETWORK}\") | .key"
(This command sorts through the name/UUID combinations, and returns the UUID that matches the network name you provided in the
_NETWORK
variable)
# Take the output from the previous
jq
command, and use it as the input into the command
tr -d \"
(This command strips all of the
"
(double-quotes) from string it is given)
# Finally, take the output from the previous
tr
command, and save it in the
_UUID
variable.
To guide you along, I'm going to show you the result of these commands on my system. Since this is the output of manually entering the commands, I'm going to be manually setting the variables. This is most evident when
_UUID
gets set, but normally the script would completely handle setting that variable.
[robert@loki ~]$ echo ${_TVHEADEND}
[robert@loki ~]$ echo ${_NETWORK}
[robert@loki ~]$ echo ${_DEVICE}
[robert@loki ~]$ export _TVHEADEND="http://10.0.0.21:9981"
[robert@loki ~]$ export _NETWORK=Charter
[robert@loki ~]$ export _DEVICE=1321F1A1
[robert@loki ~]$ echo ${_TVHEADEND}
http://10.0.0.21:9981
[robert@loki ~]$ echo ${_NETWORK}
Charter
[robert@loki ~]$ echo ${_DEVICE}
1321F1A1
[robert@loki ~]$ curl -sS "${_TVHEADEND}/api/idnode/load" -d "class=dvb_network_cablecard" -d "enum=1"
{"entries":[{"key":"bdaa87b15019374a2f0360a61c5c1438","val":"Charter"}]}
[robert@loki ~]$ curl -sS "${_TVHEADEND}/api/idnode/load" -d "class=dvb_network_cablecard" -d "enum=1" | jq ".entries[] | select(.val == \"${_NETWORK}\") | .key"
"bdaa87b15019374a2f0360a61c5c1438"
[robert@loki ~]$ curl -sS "${_TVHEADEND}/api/idnode/load" -d "class=dvb_network_cablecard" -d "enum=1" | jq ".entries[] | select(.val == \"${_NETWORK}\") | .key" | tr -d \"
bdaa87b15019374a2f0360a61c5c1438
[robert@loki ~]$ echo ${_UUID}
[robert@loki ~]$ export _UUID=$(curl -sS "${_TVHEADEND}/api/idnode/load" -d "class=dvb_network_cablecard" -d "enum=1" | jq ".entries[] | select(.val == \"${_NETWORK}\") | .key" | tr -d \")
[robert@loki ~]$ echo ${_UUID}
bdaa87b15019374a2f0360a61c5c1438
The next part of the script is where it gets the address/URL for the scanned channel lineup of your HDHR tuner.
_LINEUP=$(
curl -sS "http://api.hdhomerun.com/discover" |
jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL" |
tr -d \")
Again, like the previous snippet of the script that set the
_UUID
variable, this bit does several things to set the
_LINEUP
variable:
# Run the command
curl -sS "http://api.hdhomerun.com/discover"
(This command contacts Silicon Dust's servers and gets a listing of all of the HDHomeRun tuners and servers that are running on your local network)
# Take the output from the previous
curl
command and use it as the input to the command
jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL"
(This command returns the
LineupURL
that matches the DeviceID of the HDHR tuner that you set in the
_DEVICE
variable)
# Take the output from the previous
jq
command, and use it as input to the command
tr -d \"
(Again, this strips the
"
from the string)
# Finally, take the final output from the
tr
command, and store it in the
_LINEUP variable
[robert@loki ~]$ curl -sS "http://api.hdhomerun.com/discover"
[
{
"DeviceID": "131F3E8D",
"LocalIP": "10.0.0.49",
"ConditionalAccess": 1,
"TuningResolver": 1,
"BaseURL": "http://10.0.0.49:80",
"DiscoverURL": "http://10.0.0.49:80/discover.json",
"LineupURL": "http://10.0.0.49:80/lineup.json"
},
{
"DeviceID": "1321DC95",
"LocalIP": "10.0.0.50",
"ConditionalAccess": 1,
"TuningResolver": 1,
"BaseURL": "http://10.0.0.50:80",
"DiscoverURL": "http://10.0.0.50:80/discover.json",
"LineupURL": "http://10.0.0.50:80/lineup.json"
},
{
"DeviceID": "1321F1A1",
"LocalIP": "10.0.0.51",
"ConditionalAccess": 1,
"TuningResolver": 1,
"BaseURL": "http://10.0.0.51:80",
"DiscoverURL": "http://10.0.0.51:80/discover.json",
"LineupURL": "http://10.0.0.51:80/lineup.json"
}
]
[robert@loki ~]$ curl -sS "http://api.hdhomerun.com/discover" | jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL"
"http://10.0.0.51:80/lineup.json"
[robert@loki ~]$ curl -sS "http://api.hdhomerun.com/discover" | jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL" | tr -d \"
http://10.0.0.51:80/lineup.json
[robert@loki ~]$ echo ${_LINEUP}
[robert@loki ~]$ export _LINEUP=$(curl -sS "http://api.hdhomerun.com/discover" | jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL" | tr -d \")
[robert@loki ~]$ echo ${_LINEUP}
http://10.0.0.51:80/lineup.json
I think I'll stop there for the walk through, because those two chunks of the script set up the variables that are needed for the final @for
loop that actually creates the muxes. However, it seems as if you aren't getting to that point because the initial variables (most likely,
_UUID@) are being set.
> What bring my attention is that the output line: curl -sS http://admin:Monsrak24@127.0.0.1:9981/api/mpegts/network/mux_create -d uuid= --data-urlencode 'conf={"epg":0, "vchan":11}'
> shows empty after the uuid= . I am not sure what is an uuid (perhaps like a file checksum) but I guess I need that value when running the script.
Because you're not seeing anything after the @uuid=
in the
curl
command, it makes me believe that you haven't set the
_UUID
variable with the Tvheadend uuid of the CableCARD network.
> when I run the
http://api.hdhomerun.com/discover I get this: (no uuid value)
> [
> {
> "DeviceID": "1323B3C0",
> "LocalIP": "192.168.1.100",
> "ConditionalAccess": 1,
> "BaseURL": "
http://192.168.1.100:80",
> "DiscoverURL": "
http://192.168.1.100:80/discover.json",
> "LineupURL": "
http://192.168.1.100:80/lineup.json"
> }
> ]
No, you wouldn't have a UUID value here. The UUID comes from Tvheadned, and this information is coming from Silicon Dust; they have no knowledge about your Tvheadend servers, only the HDHR tuners and servers on your network.
> My setup:
> Tvheadend 4.3-1273~g610c6fa74
> running on a Rpi 3 with raspbian
>
> please let me know if you see what I am doing wrong or what I am missing.
>
> Thanks
Your version shouldn't matter, nor should the hardware. The problem is most likely that you've got an error of some sort when you created your script.
(Also, in the future, if you are going to post scripts or terminal output, please post it in
pre
tags so it's easier to read/understand.)