Project

General

Profile

Proper CableCARD/HDHomeRun Prime support

Added by Robert Cameron over 6 years ago

CableCARD Network support

This branch/patchset adds a CableCARD network type to Tvheadend. When adding muxes, the "Channel" field is used for the channel number as assigned by your cable provider and present in the CableCARD. After a mux has been tuned at least once (including for the discovery of the service carried on that channel), two read-only options are present as well: Callsign, which is the channel name as provided by your cable provider; and Frequency, which is the actual frequency/mux that the channel is carried on.

Because cable providers do not often populate the transport stream metadata fields, information such as a service's channel number, name and provider name are filled at creation time by information present in the mux (channel number and name) or in your network settings (in the case of the provider name).

HDHomeRun Prime

Presently, support for CableCARD networks is only exposed to the HDHomeRun driver. The new functionality in this patchset allows HDHomeRun Prime devices to be recognized as CableCARD tuners, to allow them to be set as the adapter/tuner for CableCARD networks.

Because of the way that these devices tune virtual channels as mapped by the CableCARD, each mux will only have a single service discovered on it. The reason for this is that the hardware device itself performs the PID filtering and program selection when it decrypts a channel's stream. To ensure that the PID filter is not set when using a CableCARD, all calls to PID filtering/resets have been skipped for that particular network type.

Todo

I still want to add the ability to use a device's lineup.json file to create an initial set of muxes much in the same way that pre-defined muxes are used for other network types.

Also, because there is no guide data carried on the network itself, perhaps the ability to use SiliconDust's limited 24 hour guide data provided with their device's could be implemented as a type of internal/OTA EPG grabber type.

Sources

I have created forks on GitHub for both the master development (4.3) branch, as well as a branch for the current stable/release (4.2) branch. Also, attached are the patchsets for either master or release/4.2 branches.

cablecard-4.3
cablecard-4.2


Replies (39)

RE: Proper CableCARD/HDHomeRun Prime support - Added by Ted Romer over 6 years ago

Thanks, I'm looking forward to trying this out!

A thought: short of adding support for automatically creating muxes from lineup.json, it ought to be possible to cobble together a script using the tvheadend web api, along the lines of this example https://github.com/ties/tvheadend_m3importer/blob/master/channels.py (can't vouch for it, I just Googled "/api/mpegts/network/mux_create").

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Yes, something like that might work as a stop-gap. I'll look into and possibly see about something with plain POSIX sh, curl and jq.

I've also pushed some updates and refactors to my GitHub repo for both 4.2 and 4.3, and if requested, I'll also make the diffs available, too.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Ted Romer over 6 years ago

I created a CableCard network and associated the three HDHomeRun tuners with it, and manually added muxes (through the UI) for two channels using my provider's channel numbers. The muxes go to scan status "PEND" and stay there indefinitely (10+ minutes) ... am I missing a step?

RE: Proper CableCARD/HDHomeRun Prime support - Added by Ted Romer over 6 years ago

I also tried with "Accept zero value for TSID" checked, same result.

This is running with your cablecard-4.2 branch @7ffca2488.

I enabled debug and trace output for mpegts,service,subscription,tbl-base and see the following output when adding a mux for channel 105 on network "131eb245":

mpegts: adding mux Multiplex [onid:FFFF tsid:FFFF] in 131eb245 to scan queue weight 5 flags 1000
mpegts: Multiplex [onid:FFFF tsid:FFFF] in 131eb245 - created
mpegts: 105 in 131eb245 - add raw service
subscription: 0003: creating subscription for service 105 in 131eb245 weight 5 using profile <none>
subscription: 0003: find instance for 105 in 131eb245 weight 5
subscription: 0003: "scan" unsubscribing

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Either manually choosing a mux to play will force the mux to scan for services first, and jump start the scanning of pending muxes; alternatively, restarting Tvheadend will allow the scan to proceed as normal. I believe this is related to the network not having an adapter associated with it when the mixes enter a pending state.

Also, on the adapter page for the adapter itself, not each frontend, ensure that "Remove scrambled bits" is checked. This ensures that the encrypted flag set on the stream does not cause Tvheadend to attempt to use an external descrambler.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Ted Romer over 6 years ago

I checked remove scrambled bits for each of the 3 adapters and restarted tvheadend. The muxes still stay in pending.

When I try to play the mux I get an empty response and I see this in the logs:

http: 127.0.0.1: using ticket NNN for /stream/mux/MMM
mpegts: 107 in 131eb245 - add raw service
subscription: 003F: creating subscription for service 107 in 131eb245 weight 10 using profile <none>
subscription: 003F: find instance for 107 in 131eb245 weight 10
subscription: 003F: instance not available, retrying
subscription: 003F: find instance for 107 in 131eb245 weight 10
subscription: 003F: No input source available for subscription "HTTP" to mux "107 in 131eb245" 
webui: Couldn't start streaming /stream/mux/MMM?ticket=NNN, No assigned adapters
subscription: 003F: "HTTP" unsubscribing, hostname="127.0.0.1", client="Mozilla/5.0 (X11; CrOS x86_64 10452.85.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Safari/537.36" 

RE: Proper CableCARD/HDHomeRun Prime support - Added by Ted Romer over 6 years ago

I restarted from scratch and the muxes scan just fine. Not sure what was different this time around -- perhaps I checked "Remove scrambled bits" on the tuners before adding any muxes.

Also worth noting that it is necessary to check the "Accept zero value for TSID" box for the muxes.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Ted Romer wrote:

I restarted from scratch and the muxes scan just fine. Not sure what was different this time around -- perhaps I checked "Remove scrambled bits" on the tuners before adding any muxes.

Also worth noting that it is necessary to check the "Accept zero value for TSID" box for the muxes.

Actually, the "accept zero value" is only necessary if your cable provider does not set one. I'm in Southern California on Spectrum, and I've never needed to set that. Each of my muxes has a different TSID (and sometimes they change as Charter tends to like reshuffling the channels sometimes).

However, glad to hear that it's working out for you.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Ted, I merged in your PR, and then augmented it a little. I turn off OTA EPG and idle scanning by default as well, since neither feature really works with or makes sense for a CableCARD network. I also applied the same changes to the 4.3/master branch.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Ted Romer over 6 years ago

Thanks!

Here's a quick and dirty incantation to add channels from lineup.json. jq was new to me, nifty tool.

HDHR=hdhomerun_hostname_goes_here
NETWORK="CableCARD Network" 
NETWORK_UUID=$(
  curl -s http://localhost:9981/api/mpegts/network/grid | 
    jq "$(printf '.entries | map(select(.networkname == "%s"))[0].uuid' \
          "$NETWORK")" | 
    sed -e 's@"@@g')
curl -s "http://${HDHR}/lineup.json" | 
  jq '.[].GuideNumber|tonumber' |
  while read vchan; do 
    echo $vchan
    curl --data "uuid=${NETWORK_UUID}" \
         --data "$(printf \
                  'conf={
                     "enabled":1, "epg":1,
                     "vchan":%s,
                     "scan_state":2,
                     "charset":"",
                     "tsid_zero":true,
                     "pmt_06_ac3":0,
                     "eit_tsid_nocheck":false,
                     "sid_filter":0}' \
                  $vchan)" \
         http://localhost:9981/api/mpegts/network/mux_create
    echo
  done

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

That looks good.

A couple of notes to help generalize it, perhaps for a more interactive script:
  • The endpoint /api/mepgts/network/grid returns an object with an entries array enumerating all of the configured networks.
  • A call to http://api.hdhomerun.com/discover returns an array of HDHomeRun devices on your local network, each one with an DiscoverURL key pointing to the the IP address of each individual HDHR device. (Actually, the way it works is that it returns all HDHR devices that have phoned-home to SD's servers that have the same public-facing IP address as the device that made the call to api.hdhomerun.com .)
  • A call to http://${HDHR_IP}/discover.json returns an object with a FirmwareName key that can be filtered to see if it contains "_cablecard" to ensure that only CableCARD devices are prompted for their lineups. (Also, by filtering on this field instead of checking for "PRIME" in the FriendlyName key, it ought to still work for the TECH models, as well as the new 6-tuner Prime when it is eventually released.)

Hopefully by this weekend I may have some more time to fiddle around with it and see what I can come up with, too.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

For those tracking this fork, I'd like to mention that it has been merged into master/4.3. For release/4.2 you can still pull from my cablecard-4.2 branch which will maintain feature parity with any changes to this feature-set made to master.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Ted, I liked your script, and I pulled in a couple points from yours when crafting mine. They're essentially the same. Ultimately the goal is to allow for either interactive use, or to have it default to the first CableCARD network and first _cablecard HDHomeRun device unless a configuration file is found.

#!/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

_UUID=$(
  curl -sS "${_TVHEADEND}/api/idnode/load"                 \
    -d "class=dvb_network_cablecard" -d "enum=1"           |
  jq ".entries[] | select(.val == \"${_NETWORK}\") | .key" |
  tr -d \")

_LINEUP=$(
  curl -sS "http://api.hdhomerun.com/discover"                |
  jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL" |
  tr -d \")

for _CHANNEL in $(
  curl -sS "${_LINEUP}" |
  jq '.[].GuideNumber | tonumber')
do
  curl -sS "${_TVHEADEND}/api/mpegts/network/mux_create" \
    -d "uuid=${_UUID}"                                   \
    --data-urlencode "conf={\"epg\":0, \"vchan\":${_CHANNEL}}" > /dev/null
done

RE: Proper CableCARD/HDHomeRun Prime support - Added by Reggie Burnett over 6 years ago

Well done Robert! Going to see if the linuxserver tvheadend docker image has been updated to include this.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Reggie Burnett over 6 years ago

Also thanks to Ted and Robert for the script. Saved me some time creating all my muxes. Whew!

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

When using a script that pulls the lineup.json from the tuner, it might be best disable the channels in the tuner's webui for those you don't care about. By default when requesting lineup.json channels that are disabled (have the red X) are not listed in the lineup.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Yusef Neblett over 6 years ago

Robert Cameron wrote:

Ted, I liked your script, and I pulled in a couple points from yours when crafting mine. They're essentially the same. Ultimately the goal is to allow for either interactive use, or to have it default to the first CableCARD network and first _cablecard HDHomeRun device unless a configuration file is found.

[...]

Hi Robert,

Can you please share how to run your script?
I have installed the tvhd 4.3 with CableCard drivers and trying to make it work.

Thanks

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Yusef Neblett wrote:

Robert Cameron wrote:

Ted, I liked your script, and I pulled in a couple points from yours when crafting mine. They're essentially the same. Ultimately the goal is to allow for either interactive use, or to have it default to the first CableCARD network and first _cablecard HDHomeRun device unless a configuration file is found.

[...]

Hi Robert,

Can you please share how to run your script?
I have installed the tvhd 4.3 with CableCard drivers and trying to make it work.

Thanks

Create a CableCARD network in Tvheadend. Then, in the script, set the variables for your particular needs:
  • _TVHEADEND – This is the URL you use to access your Tvheadend server. If you need a user/pass, include it in the URL, such as http://user:[email protected]:9981
  • _NETWORK – This is he name of the CableCARD network you created in Tvheadend
  • _DEVICE – This is the DeviceID of the HDHomeRun Prime that has your channel lineup. You need to have run a channel scan through the device's web UI first; and channels that you don't want to have added to Tvheadend can be disabled in the Prime's web UI, and they will be ignored when creating muxes

After you've made those adjustments, just run the script. When the script completes its run, you will have a mux for each channel of your Prime that hasn't been disabled.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Yusef Neblett over 6 years ago

Thanks Robert for your time,

Just to be clear in what commands to use to run the srcipt. Should I create the script file xxxx.sh or xxx.py? and I guess the file path used to run the script doesnt matter correct?

I have basic linux knowledge on scripts.

Appreciatte your time

YN

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Yusef Neblett wrote:

Thanks Robert for your time,

Just to be clear in what commands to use to run the srcipt. Should I create the script file xxxx.sh or xxx.py? and I guess the file path used to run the script doesnt matter correct?

I have basic linux knowledge on scripts.

Appreciatte your time

YN

Name it whatever you like, it doesn't matter. Just make sure it's marked as executable. If you're going to give it an extension, .sh is most appropriate. The shebang in the first line of the script (#!/bin/sh) tells your command processor to use a POSIX shell to execute the script.

Also note, you need both curl and jq for my script to work. curl is part of most every distribution, but jq usually needs to be installed separately.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Yusef Neblett over 6 years ago

Hi Robert,

jq and curl are installed. I have created a script file with .sh containing your script as your adviced:

#!/bin/sh
_TVHEADEND="http://myadminuser:adminpass@localhost:9981" #URL used to access Tvheadend WebUI
_NETWORK=hdhomerun-CC #Name of CableCARD network to add muxes to
_DEVICE=1323B3C0 #DeviceID of HDHomeRun device

_UUID=$(
curl -sS "${_TVHEADEND}/api/idnode/load" \
-d "class=dvb_network_cablecard" -d "enum=1" |
jq ".entries[] | select(.val == \"${_NETWORK}\") | .key" |
tr -d \")

_LINEUP=$(
curl -sS "http://api.hdhomerun.com/discover" |
jq ".[] | select(.DeviceID == \"${_DEVICE}\") | .LineupURL" |
tr -d \")

for _CHANNEL in $(
curl -sS "${_LINEUP}" |
jq '.[].GuideNumber | tonumber')
do
curl -sS "${_TVHEADEND}/api/mpegts/network/mux_create" \
-d "uuid=${_UUID}" \
--data-urlencode "conf={\"epg\":0, \"vchan\":${_CHANNEL}}" > /dev/null
done

I am using @localhost:9981 because I am running the script in the tvhd server, I tried changing to the server Ip as well.

I am running the script with:
./myscript.sh

But I keep getting this error: parse error: Invalid numeric literal at line 1, column 10

I checked the script and look ok to me but I cant figure out the root cause of the issue.

Thanks for your time again.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

Sounds like a problem logging in to your Tvheadend server. However, wihout details I can't be specific.

Try running the commands manually from the command line; slowly adding the piped commands to each command and substituting the literal text for the variables.

Unfortunately, beyond that I'm not sure what additional help I can offer.

RE: Proper CableCARD/HDHomeRun Prime support - Added by Yusef Neblett over 6 years ago

Hi Robert,

Thanks for your help, I been trying to figur out the reason for the script not working to me. and I have a question:

I run the cablecard.sh script:

root@raspberrypi:/media/tvhd# bash -x cablecard.sh
+ _TVHEADEND=http://admin:[email protected]:9981
+ _NETWORK=CCPrime
+ _DEVICE=1323B3C0
+ curl -sS http://admin:[email protected]:9981/api/idnode/load -d class=dvb_network_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 http://api.hdhomerun.com/discover
+ 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:[email protected]:9981/api/mpegts/network/mux_create -d uuid= --data-urlencode 'conf={"epg":0, "vchan":11}'
+ for _CHANNEL in $(
curl -sS "${_LINEUP}" |
jq '.[].GuideNumber | tonumber')

What bring my attention is that the output line: curl -sS http://admin:[email protected]: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.

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"
}
]

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

RE: Proper CableCARD/HDHomeRun Prime support - Added by Robert Cameron over 6 years ago

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=http://admin:[email protected]:9981
+ _NETWORK=CCPrime
+ _DEVICE=1323B3C0
+ curl -sS http://admin:[email protected]:9981/api/idnode/load -d class=dvb_network_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 http://api.hdhomerun.com/discover
+ 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:[email protected]: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:
  1. 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.
  2. 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:
  1. 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)
  2. 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)
  3. 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)
  4. 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:
  1. 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)
  2. 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)
  3. 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)
  4. 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:[email protected]: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.)

RE: Proper CableCARD/HDHomeRun Prime support - Added by Yusef Neblett over 6 years ago

Hi Robert,

Thanks so so much for your help and explanation. I realize the issue was a loggin issue to the tvheadend server now with your help. Thanks so mush!!

When I was running the script line by line, I got an error when trying to call the tvheadend server:

root@raspberrypi:/media/tvhd# curl -sS "${_TVHEADEND}/api/idnode/load" -d "class=dvb_network_cablecard" -d "enum=1" 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>401 Unauthorized</TITLE>
</HEAD><BODY>
<H1>401 Unauthorized</H1>
<P STYLE="text-align: center; margin: 2em"><A HREF="/" STYLE="border: 1px solid; border-radius: 4px; padding: .6em">Default

So I created a new user that will not require password to loging and ran the script as you adviced: ./script.sh

Thanks for your time and work. I really appreciate it.

Yusef

(1-25/39)