- JavaScript 50.7%
- Python 18.1%
- Shell 9.8%
- HTML 6.2%
- CSS 6%
- Other 9.2%
tv200
A browser-based open source smart TV platform
Features
If you have a Linux computer or Raspberry Pi 4+ connected to your TV, tv200 lets you control it from an arbitrary number of phones and computers. You send a link and the TV shows or plays it. It supports the following features:
- A multi-platform, multi-user editable queue
- Automatic conversion of music links from all common platforms to your preferred platform
- Integration with VLC to seemlessly play movies, music and playlists
- Change TV volume and turn TV on and off (only on devices that support CEC like the Raspberry Pi)
- Casting of local files to the TV
- Easily open videos on the player device with a built-in file browser
- Display arbitrary content in the file browser with custom listings
- Downloading torrents can be as simple as sending a magnet link
- CLI client, ideal for scripting
Supported services
Play/pause/skip work on these platforms:
- Youtube (you can also seek within a video)
- Youtube Music
- Spotify
- Pandora
- Arbitrary sites with HTML5 videos (though support is not as good)
- More can be added quite easily, PRs welcome
Setup guide
- Clone this repository onto the Linux computer connected to your TV
- Close any open Chrome windows
- Run
scripts/interactive-setup.sh, which will guide you through the setup process (most steps are optional) - Run
scripts/start-system.sh(or just reboot, if you enabled autostart) - Go to tv.phie.me from another device
- Type in the code that's displayed on your TV
- Copy the URL of a public video you want to watch
- Click on the wide play button in the middle of the screen and paste the URL to play your video
scripts/start-system.sh launches the browser+player extension, and runs a local webserver for various features not available directly from a browser. You can use scripts/interactive-setup.sh to install all recommended packages and set up other features (autostart on boot, torrenting, etc.). This script officially supports the Raspberry Pi 4 and 5 running Raspberry Pi OS, your your mileage may vary on other platforms, but it's a useful reference regardless.
See documentation.md for more details and internal documentation.
Configuration
By default many features are disabled. They can be enabled with a config file in one of the following locaitons:
<repo-root>/config.json/etc/tv200.json~/.config/tv200.json<repo-root>/override-config.jsonValues absent from your config fall back to those in player/default-config.json. winter-config.json is my personal config with all features enabled.
You can reload configuration (respected by both system and player) by, on the player's keyboard, pressing ESC and then C.
auto-updates
true/false. If to run git pull and restart the browser when an update is detected from the backend. Does NOT change your branch, just pulls.
backend-url
The URL of where backend/main.py is running. You are welcome but not required to use my deployment. If you're running backend/main.py locally, use http://localhost:5055.
token
The token used to identify/authenticate this player to the server. Must have originally come from /API/new_player_token, and may expire if unused for a while. Setting this value is not required, but it can be useful in some cases. For example if you have lots of paired devices or print out a QR code with your [stable pairing code](/documentation.md#Stable pairing codes), you may want to be able to switch devices without changing token. Typically you'd first run your player with this value unspecified, copy the token it automatically fetches to the clipboard with ESC+t on the player device and then add that to the config. If the token is invalid or expired the TV will not connect to the server until it is removed from the config.
preferred-music-services
An array of domains. When a user sends a link to a known service not on the list, the TV attempts to convert the link to a service on this list with Songlink. This is useful if, for example, you have a Spotify subscription but your guest shares a song from Apple Music. Earlier enteries are preferred over later enteries. See player/home/linkLoading.js for the full list of services that can be converted to/from.
power-mode
How TV power is toggled, options are null and "cec".
For CEC libcec must be installed and device must have hardware support (Raspberry Pis support CEC, most other devices don't). Currently the default CEC port is used, which means the TV must be connected to the HTMI port nearest the power port on the Pi 5.
power-on-delay
Number of milliseconds to wait before playing something after powering on the TV. Some TVs may take a few seconds to power on, or have sound systems that take a few seconds to power on, making it problematic to start playing a video immediately when the TV was previously off.
volume-mode
How volume is changed, options are null, "cec" and "pulse". Same caveats for CEC as above. Pulse reqires the pactl command.
file-browsing-root
null to disable file browsing, else a directory users can browse through from the control app's Downloads menu. The contents of files are not sent, only file names and directory structure. When a user clicks on a file its path is sent back to the player to play it. Note that the entire subdirectory tree is traversed and serialized every time a user browses files, so a directory with too many things in it might bog the system down. You can load listings other than local files in the file browser UI, see Custom listings for details.
torrenting
true/false. If to automatically start qBittorrent and download torrents when magnet links are sent to the TV".
torrenting-netns
The network namespace to run qBittorrent within. Useful for using a VPN only with qBittorrent. Has no effect if torrenting is disabled. Set to null to not run within a network namespace. Set to "wireguard-vpn" if using the network namespace the the setup scripts created. Passwordless sudo is required to use a network namespace, but qBittorrent is not run as root.
Troubleshooting
The easiest way to fix most problems is to restart the TV's computer.
To reset the TV's state and force all devices to re-pair with a new code press Escape on the TV device and then press R.
Torrenting
The interactive-setup.sh script optionally sets up a number of things to enable torrenting. Notably it can:
- Create a network namespace
- Prompt the user for their Mullvad account
- Set up a VPN connection (which is only used inside the network namespace, not by the browser or rest of the system)
- Set up localhost port forwarding so the browser can talk to programs running in the network namespace
- Configure qBittorrent
Even if you set up qBittorrent from the setup script, you still need to set torrenting and (optionally) torrenting-netns in your config. The VPN/network namespace is only required if you want your torrent client to use a VPN and the rest of the system to not be on the VPN.
If you need control over the running qBittorrent beyond just adding magnet links, send http://localhost:5057 to the TV the same way you would a video. You can then a keyboard/mouse connected to the TV device to mess with its web UI.