Locast2plex on FreeNAS Please Help

With Football starting and my antenna not always being reliable I started looking into Locast. (local channel steaming service for $5 a month). Well i came across Locast2Plex that would let me add it to Plex. Locast2plex is a prebuilt Docker image that I’m not sure how to set up in FreeNAS. I came across a post on Reddit with the person saying they got it running in a jail. If anyone has set this up. I would love some help and or directions on how to accomplish this. I’m running 11.3 currently.

I haven’t(yet) installed Plex on my NAS, but it looks like Locast2Plex can be run as either a container, or as a python script with ffmpeg as a dependency.

The readme on the Locast2Plex repo says it’s been tested only in Windows. I haven’t looked at the code, but if the script just makes service calls back to Locast, and then acts as a wrapper around ffmpeg, then it’ll probably work in a jail also without too many shenanigans. That’s probably where I’d start since trying to get a docker container running in a VM on FreeNAS just for this instead of using a jail is probably more trouble than it’s worth.

Are you comfortable with installing packages, and administering jails from the command line?

1 Like

Assuming you are, I gave it a shot, but I do not have a valid account to test further.

Begin by creating a jail, e.g. locast2plex

enter the shell of your jail with sudo iocage console locast2plex or the jail name you have chosen. You are now logged in as root in the jail.

install dependancies like: pkg install python2.7 ffmpeg wget

add a user to run the service with the adduser tool. login to this user with su username and cd ~

download your release of choice in tar.gz format. I tested 0.4.2. wget https://url.to.release and extract tar -xf 0.4.2 or change the filename.

now enter the locast directory cd locast2plex-0.4.2 and start the application like python2.7 main.py -u:username -p:password

I can’t test further as I don’t have an account.

1 Like

Thanks a bunch guys.

I’ll be trying this later tonight and see how it goes. I should be able to get this working with these directions.

I used these steps and it doesn’t seams to want to finish connecting. not sure whats going on i have upnp turned on on my edge router4

  1. Loged in as Root

  2. Create Jail locast2plex
    Basejail - yes
    VNET – yes
    Berkeley Packet Filter – yes
    IPv4 Interface – vnet0
    IPv4 Address - 192.168.1.32
    IPv4 Netmask – 24
    IPv4 Default Router – my default router
    Auto-Start – yes

  3. Go to Shell and input

    3a. get to locast jail: iocage console locast2plex

    3b. install dependencies: pkg install python2 ffmpeg wget

    3c. download your release of choice in tar.gz format: wget https://github.com/tgorgdotcom/locast2plex/archive/0.4.2.tar.gz

    3d. Extract: tar -xf 0.4.2.tar.gz

    3e. Now enter the locast directory: cd locast2plex-0.4.2

    3f. Start the jail: python2 main.py -u:my username -p:my password --addy:192.168.1.32

When i do that i get this and it never finishes.
Locast2Plex v0.4.2
UUID found.
UUID set to: random numbers letters
\Logging into Locast using username my username…
Validating User Info…
User Info obtained.
User didDonate: True
User donationExpire: 1604934904
Getting user location…
User location obtained as 42.5763/-71.9883
Getting user’s media market (DMA)…
DMA found as 506
Getting list of stations based on DMA…
Loading FCC Stations list…
Starting device server on 0.0.0.0:6077
Starting SSDP server…
192.168.1.31 - - [09/Sep/2020 15:32:32] “GET /device.xml HTTP/1.1” 200 -

What happens when you point Plex at 192.168.1.32?

The purose of this is to allow Plex to talk to Locast using this python script, so my guess is it’s not supposed to “finish”, but just sit there and listen for connections.

1 Like

it says there was a problem adding the device

So what’s the problem? Does Plex have an error log which can give you more details?

i cant seam to find an error in plex

i figured it out i had to add “:6077” to point to it

1 Like

These are the full directions to get it up and running in a jail and attaching it to Plex.

  1. Log in as Root or “sudo” will be needed

  2. Create Jail locast2plex
    Basejail - yes
    VNET – yes
    Berkeley Packet Filter – yes
    IPv4 Interface – vnet0
    IPv4 Address – set static ip
    IPv4 Netmask – 24 (normal also known as 255.255.255.0)
    IPv4 Default Router – your router ip
    Auto-Start – yes

    2a. Start Jail

  3. Go to Shell and input

    3a. If Root user: iocage console locast2plex if not Root user: sudo iocage console locast2plex

    3b. install dependencies: pkg install python2 ffmpeg wget

    3c. download your release of choice in tar.gz format: wget https://github.com/tgorgdotcom/locast2plex/archive/0.4.2.tar.gz

    3d. Extract: tar -xf 0.4.2.tar.gz

    3e. Now enter the locast directory: cd locast2plex-0.4.2

    3f. Start the jail: python2 main.py -u:Username -p:Password –addy:static ip (I.E. 192.168.#.###)

  4. Restart locast2plex jail

  5. Go into Plex – Settings – Live TV & DVR

    5a. Click Add Device

    5b. Click enter manually

    5c Put in the static ip address:6077 and it should show up just like an antenna.

The only thing i need help with is setting it up so it says running when i close the shell

2 Likes

tmux is your friend. :stuck_out_tongue_closed_eyes:

pkg install tmux

2 Likes

oh goody more to learn. lol

Or you could set it up as a service and give it an init script so it starts automatically when you bring up the jail and you don’t even have to think about it. That’s probably the “correct” way to do it, but tmux will do the job if you’re not super interested in digging into the dirty details.

3 Likes

I applaud your efforts, glad to see you got it working from just the outline provided. TMUX is a fine way to set a service running, note that it will have to be re-run everytime you reboot the jail. In a sense you are building your own container here. Docker is “popular” so many devs support it, and create the conatiner for you, but the FreeNAS equivalent is a plugin, and the supported apps are listed in the FreeNAS UI. You can use other community supported plugins as guideline here, but I’ll make an effort to provide one for you.

You will want to create a service file in the following directory mkdir -p /usr/local/etc/rc.d. More details in the FreeBSD documentation (link). Lets call the service locast2plex, so we create the file like ee /usr/local/etc/rc.d/locast2plex

Then copy and paste the following into your service file

#!/bin/sh

. /etc/rc.subr

name=locast2plex
rcvar=locast2plex_enable

start_cmd="${name}_start"
stop_cmd=":"

load_rc_config $name
: ${locast2plex_enable:=no}

locast2plex_start()
{
    su -m locast2plex -c "/usr/local/bin/python2 /home/locast2plex/main.py -u:username -p:password -addy:192.168.x.x"
}

run_rc_command "$1"

NOTE: this script assumes you want to run the services as the user locast2plex. Change the comman to su -m username -c "..." for another username or simply replace the line to be the part in quotations to run as root. Please don’t run such a service as root.

NOTE: this script provides the absolute minimum to start the service with no logs, etc.

make your service file executable, chmod +x /usr/local/etc/rc.d/locast2plex

enable your service in /etc/rc.conf by appending the file with the lines

# Enable locast2plex
locast2plex_enable="YES"

and finally start your service with service locast2plex start

2 Likes

Awesom

Thank you for that i have been racking my brain as to where i need to put that and how to go about writing it. And where it needs to go. I do a little coding but this is a bit out of my league.

im guessing the username, password, and ip address is all my information

1 Like

When i go to start the service i get

/usr/local/bin/python2: Command not found.

Is this because python is technical installed in the jail.

I just ssh’d to that location and found i only have python, then it goes to python3

In your jail, try:

which python

and use that path to replace /usr/local/bin/python2

1 Like

which python didnt work in the jail

But i think i put the rc.d in the wrong location. I put it in the most top level of freenas and it actually belongs in the jail. I did some searching and found that the rc.d code for plex was only in the jail. I am now looking for the rc.conf file that starts plex and i will make sure the locast2plex is in the same location in locast2plex. Using WinSCP to do the search now.