Whatbox Logo
Login for certain variables to be updated with your slot's information

Wiki > Threadfin

Threadfin is an M3U proxy for Plex DVR and Jellyfin/Emby Live TV, based on xTeVe. It combines your M3U playlists and XMLTV guide data and presents them to your media server as an HDHomeRun tuner or as an M3U/XMLTV pair.

27541 was randomly generated for this article; you may use any 5-digit port between 10000 and 32767. Threadfin's default port, 34400, can't be used on Whatbox.

Create your Threadfin user in step 6 before you open Threadfin up in step 7. Until a user exists, whoever opens the web interface first can create one.

Installation

  1. Connect to your slot via SSH.

  2. Download Threadfin:

     mkdir -p ~/bin && wget https://github.com/Threadfin/Threadfin/releases/latest/download/Threadfin_linux_amd64 -O ~/bin/Threadfin_linux_amd64 && chmod +x ~/bin/Threadfin_linux_amd64
    
  3. Create Threadfin's settings file in ~/.threadfin:

     ~/bin/Threadfin_linux_amd64 -info
    
  4. Set your port, turn off network discovery (SSDP), keep Threadfin private to your slot for now, and turn on web authentication:

     sed -i 's/"port": "34400",/"port": "27541",/' ~/.threadfin/settings.json
     sed -i 's/"ssdp": true,/"ssdp": false,/' ~/.threadfin/settings.json
     sed -i 's/"bindIpAddress": "[^"]*",/"bindIpAddress": "127.0.0.1",/' ~/.threadfin/settings.json
     sed -i 's/"authentication.web": false,/"authentication.web": true,/' ~/.threadfin/settings.json
    
  5. Start Threadfin:

     screen -dmS threadfin /home/user/bin/Threadfin_linux_amd64
    
  6. Create your Threadfin user. You'll be asked for a username and a unique password (do not reuse your Whatbox password):

     read -rp 'Username: ' tf_user; read -rsp 'Password: ' tf_pass; echo
     curl -s -o /dev/null --data-urlencode "username=$tf_user" --data-urlencode "password=$tf_pass" --data-urlencode "confirm=$tf_pass" http://127.0.0.1:27541/web/; unset tf_user tf_pass
    
  7. (Optional) If you plan to use HTTPS only, skip this step and set up HTTPS via Managed Links instead. Otherwise, make Threadfin reachable from outside your slot and restart it:

     sed -i 's/"bindIpAddress": "127.0.0.1",/"bindIpAddress": "0.0.0.0",/' ~/.threadfin/settings.json
     pkill -fx "/home/user/bin/Threadfin_linux_amd64"; sleep 2; screen -dmS threadfin /home/user/bin/Threadfin_linux_amd64
    
  8. Visit http://server.whatbox.ca:27541/web/ (or your Managed Link address if you skipped step 7) and log in with the user from step 6.

Configuration

Threadfin doesn't have its own documentation yet; it follows xTeVe's documentation.

  • Playlists and guide data: add your M3U playlists under Playlist and your XMLTV files under XMLTV, then map the channels you want under Mapping.
  • Connecting Plex: in Plex, go to Settings → Live TV & DVR → Set up Plex DVR. If Plex doesn't find Threadfin, enter server.whatbox.ca:27541 as the tuner address.
  • Connecting Jellyfin or Emby: add a tuner of type M3U Tuner with http://server.whatbox.ca:27541/m3u/threadfin.m3u and a guide provider of type XMLTV with http://server.whatbox.ca:27541/xmltv/threadfin.xml. The guide link only works once you've added XMLTV data and mapped channels.
  • Streaming: by default Threadfin sends players straight to the original stream and doesn't buffer it. Leave the buffer setting off unless a provider needs it; every stream Threadfin buffers counts toward your slot's traffic.
  • Playlist and guide links: anyone with the address can download your M3U and XMLTV files. To require a login for them, enable M3U and XML authentication under Settings and give your media server the username and password in the link.

Automatically Restart (optional)

This script starts Threadfin if it isn't running, for example after the server reboots.

  1. Create a restart script:

     touch ~/threadfin_restart.cron
     nano -w ~/threadfin_restart.cron
    
  2. Paste in the following:

     #!/bin/bash
     export TMPDIR=/home/user/.tmp
     if pgrep -fx "/home/user/bin/Threadfin_linux_amd64" > /dev/null
     then
         echo "Threadfin is running."
     else
         echo "Threadfin is not running, starting Threadfin"
         screen -dmS threadfin /home/user/bin/Threadfin_linux_amd64
     fi
     exit
    

    Save with Ctrl + S and exit with Ctrl + X.

  3. Make the script executable:

     chmod +x ~/threadfin_restart.cron
    
  4. Open your crontab:

     EDITOR=nano crontab -e
    
  5. Add these lines, then save and exit:

     @reboot /home/user/threadfin_restart.cron >/dev/null 2>&1
     */5 * * * * /home/user/threadfin_restart.cron >/dev/null 2>&1
    
  1. On the Manage Links page, click Add a custom app.

  2. Name it threadfin, enter port 27541, and open Advanced options to enable WebSockets, which Threadfin's interface needs.

  3. Visit https://threadfin.example.box.ca/web/ and log in.

  4. If you opened Threadfin up in step 7 of Installation and no longer need the plain HTTP port, make it private again and restart Threadfin:

     sed -i 's/"bindIpAddress": "0.0.0.0",/"bindIpAddress": "127.0.0.1",/' ~/.threadfin/settings.json
     pkill -fx "/home/user/bin/Threadfin_linux_amd64"; sleep 2; screen -dmS threadfin /home/user/bin/Threadfin_linux_amd64
    

    In your media server, use https://threadfin.example.box.ca/m3u/threadfin.m3u and https://threadfin.example.box.ca/xmltv/threadfin.xml.

Updating

Threadfin checks for a new version every time it starts and updates itself. To update, restart it:

pkill -fx "/home/user/bin/Threadfin_linux_amd64"; sleep 2; screen -dmS threadfin /home/user/bin/Threadfin_linux_amd64

To update by hand instead, stop Threadfin with the pkill command above, repeat step 2 of Installation, then start it with step 5. Your settings in ~/.threadfin are kept.

Upgrading from the previous version of this article

Threadfin's binary and settings are in the same places as before, so your playlists and mappings are kept.

  1. The previous instructions gave the port on the command line; the new start command reads it from the settings file. Check it with grep '"port"' ~/.threadfin/settings.json. If it shows 34400, set your port with the first sed command from step 4 of Installation.

  2. The previous instructions started Threadfin open to everyone before a user was created. Make sure WEB Authentication is enabled under Settings and that you can log in.

  3. Stop the copy started by the previous instructions, then start Threadfin the new way, which also updates it:

     pkill -fx "/home/user/bin/Threadfin_linux_amd64 -port=.*"; sleep 2; screen -dmS threadfin /home/user/bin/Threadfin_linux_amd64
    
  4. Set up the restart script if you want one.

Uninstalling

This deletes your playlists, mappings and settings.

  1. Remove the two threadfin_restart.cron lines from your crontab (EDITOR=nano crontab -e).

  2. Stop Threadfin and delete its files:

     pkill -fx "/home/user/bin/Threadfin_linux_amd64"
     rm -rf ~/.threadfin ~/.tmp/threadfin
     rm -f ~/bin/Threadfin_linux_amd64 ~/threadfin_restart.cron
    
  3. If you set up a Managed Link, delete it from the Manage Links page.

Troubleshooting

  • The page asks you to create a user instead of logging in: step 6 didn't work. Run it again, then reload the page.
  • Threadfin says it's running on port 34400: the port wasn't set. Run the first sed command from step 4 of Installation, then restart Threadfin.
  • The page doesn't load at http://server.whatbox.ca:27541/web/: check that bindIpAddress in ~/.threadfin/settings.json is 0.0.0.0 (step 7 of Installation); 127.0.0.1 only allows the Managed Link. Remember the /web/ at the end of the address.
  • Forgot your Threadfin password: stop Threadfin, make it private with the sed command from step 4 of HTTPS via Managed Links, delete the user file with rm ~/.threadfin/authentication.json, start Threadfin with step 5 of Installation, create a new user with step 6, then open it up again with step 7.
  • The restart script starts a second copy, or never starts Threadfin: check that both commands in threadfin_restart.cron match the ones above exactly, including the full /home/user/bin/Threadfin_linux_amd64 path.
  • Anything else: ask on Threadfin's Discord server, linked from its GitHub page.