Skip to content
248TechPublic

About

Send YouTube videos to your Fire TV from Chrome or Telegram, with a real play queue. Plays in SmartTube via ADB; tiny Python helper for Raspberry Pi or Windows.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TubeQueue logo

TubeQueue

Send YouTube videos to your Fire TV from Chrome or Telegram, with a real play queue.
One click in the YouTube player or a share from your phone, and the video plays on the TV in SmartTube. Send more while it plays and they line up instead of interrupting.

Latest release CI Python 3.10+, no dependencies Fire TV and Android TV MIT license Website

A phone chat with the TubeQueue bot (playing, queued, up next) beside a TV playing the video with the queue listed

The Fire TV YouTube app can't be cast to from a desktop browser, and casting from a phone replaces whatever is on screen. TubeQueue fixes both. A small helper, on a Raspberry Pi or your PC, drives the TV over ADB on your Wi-Fi. A Chrome extension and a Telegram bot feed it videos.

Features

  • Send to TV button inside the YouTube player, plus Alt+Shift+T and a toolbar icon. The video opens on the TV at the same timestamp, and the browser tab pauses.
  • Telegram bot. Share a YouTube link from the YouTube app on your phone to your bot. Works from anywhere, with no port forwarding.
  • A real queue. Links that arrive while a video is playing wait their turn and start when it ends. Several links in one message queue in order. The bot tells you what's up next.
  • Knows when a video ends. It reads the TV's media session (play state and position) and compares it with the video's length. It also notices when SmartTube autoplays something else or you stop playback.
  • Back. back replays the previous video, and you can repeat it to go further back.
  • Plays in SmartTube (ad-free YouTube client for Android TV) when installed, otherwise the official YouTube app.
  • Runs anywhere Python does. It needs Python 3.10+ and the standard library only, nothing to pip install. A Raspberry Pi keeps it on 24/7 with a systemd user service and no root.
  • Finds the TV by itself on your network (SSDP) and follows it if its IP changes.
  • See the TV on your PC. tvscreen.py mirrors the Fire TV's screen to a window with scrcpy. Your keyboard and mouse work as the remote, and it can record to a file.

How it works

flowchart LR
  A["Chrome extension<br/>(YouTube player button)"] -- "HTTP :8799" --> H
  B["Telegram bot<br/>(share from phone)"] -- "long polling<br/>(outbound only)" --> H
  H["TubeQueue helper<br/>Raspberry Pi or PC<br/>queue + history"] -- "ADB over Wi-Fi" --> T["Fire TV<br/>SmartTube / YouTube"]
  T -. "media session<br/>(state, position)" .-> H
Loading

Amazon blocks third-party DIAL launches of YouTube on Fire TV, so TubeQueue uses ADB (am start with a YouTube deep link). It polls dumpsys media_session every few seconds to see when the current video has finished.

Quick start

You need a Fire TV (any Fire TV Stick, Cube or Fire TV smart TV, or another Android TV) and something to run the helper. A Raspberry Pi is ideal because it's always on; any Linux box or a Windows PC works too.

1. Turn on ADB debugging on the Fire TV

Settings → My Fire TV → About → click the device name 7 times to unlock Developer Options. Then Settings → My Fire TV → Developer Options → ADB Debugging: ON.

Optional: install SmartTube on the TV for ad-free playback. TubeQueue falls back to the official YouTube app without it.

2. Install the helper

Raspberry Pi / Linux
sudo apt install adb python3          # no sudo? run scripts/adb-no-root.sh instead of installing adb
git clone https://github.com/248Tech/TubeQueue.git
cd TubeQueue
./install.sh                          # systemd user service, starts at boot, reachable from your LAN

./install.sh --tv 192.168.1.40 sets the TV's IP explicitly. --local keeps the helper private to this machine, and --uninstall removes it.

Windows
winget install Google.PlatformTools   # adb
# download and unzip the latest release (or git clone), then in that folder:
.\install.ps1                         # Startup shortcut, runs hidden, no admin

Add -Lan if Chrome runs on a different PC. -Uninstall removes it.

The first time TubeQueue connects, the TV shows "Allow USB debugging?". Tick Always allow from this computer and press OK.

3. Add the Chrome extension

chrome://extensions → enable Developer mode → Load unpacked → pick the extension folder. The options page opens. Enter the helper address, for example http://127.0.0.1:8799 for this PC or http://<pi-ip>:8799 for a Pi, and press Save & test.

Open any YouTube video and click the TV icon in the player controls.

4. Optional: Telegram bot

  1. In Telegram, message @BotFather → /newbot → copy the token.
  2. Run ./telegram-setup.sh (or .\telegram-setup.ps1) and paste the token. It's read from a hidden prompt.
  3. Message your bot. It replies "Not authorized. Your Telegram user id is N".
  4. Allow yourself: ./telegram-setup.sh --allow N (or .\telegram-setup.ps1 -Allow N).

Now share any YouTube video to the bot.

Bot commands

Send What happens
a YouTube link Plays now if the TV is free, otherwise queued: 📋 Queued #2: title [12:34]
several links in one message All queued, in order
now <link> Interrupts and plays right away (the queue is kept)
queue / q What's playing and what's queued
skip / next Play the next queued video now
clear Empty the queue
back / prev Play the previous video (repeat to go further back)
pause Play / pause
status Is the TV reachable?

Commands work with or without the /. When the queue advances on its own, the bot posts ▶ Up next from queue: ….

The Chrome button always plays immediately, because a click is a deliberate "watch this now". Queued videos continue after it ends.

See the TV screen on your PC

Mirror the Fire TV to a window on your computer. This works from any PC on your network, even when the helper runs on a Raspberry Pi, because the TV accepts several ADB connections at once.

winget install Genymobile.scrcpy            # Debian / Pi: sudo apt install scrcpy · macOS: brew install scrcpy
python helper/tvscreen.py                   # finds the TV and opens the window
python helper/tvscreen.py --shortcut        # Windows: "Fire TV Screen" icon on the Desktop
Option
--tv 192.168.1.40 TV address. By default it uses tv_ip from config.json, or finds the TV on the network.
--view-only Watch only, with no input sent to the TV.
--record tv.mkv Also record to a file.
--bitrate 4M, --max-size 1280 Lighter stream for weak Wi-Fi.
--audio Also try to forward sound. Fire OS usually refuses audio capture.

Unless --view-only is set, the window controls the TV. Arrow keys and Enter work as the D-pad, right-click is Back, and middle-click is Home.

Apps with DRM (Netflix, Prime Video, Disney+) and HDMI inputs show up black, because Fire OS blocks capturing them. SmartTube and YouTube mirror fine.

Configuration

helper/config.json is created by the installers. See config.example.json.

Key Default
tv_ip "" Fire TV address. Empty means find it on the network, then remember it.
app org.smarttube.stable Player package. Falls back to com.amazon.firetv.youtube.
bind 127.0.0.1 0.0.0.0 makes the helper reachable from your LAN (Pi setups).
port 8799 HTTP port for the extension.
telegram_token Set by telegram-setup.
telegram_allowed_ids [] Telegram user ids allowed to control the TV.
telegram_max_age_s 120 Messages older than this (sent while the helper was offline) aren't replayed.

Troubleshooting

  • "Can't reach the TV": check the TV is on and ADB debugging is still on. Some Fire TVs turn it off after a reboot or update. Then run adb connect <tv-ip>:5555.
  • "unauthorized": accept the Allow USB debugging? prompt on the TV.
  • The extension says it can't reach the helper: check the address in the extension options. On a Pi, make sure bind is 0.0.0.0 (install.sh does this) and that systemctl --user status tubequeue is active.
  • Logs: helper/tubequeue.log. Run python3 helper/tubequeue.py in a terminal to watch live.
  • Live streams have no length, so the queue can't tell when they end. Use skip.

FAQ

Is it free? Yes, under the MIT license.

Does my PC need to stay on? No, if the helper runs on a Raspberry Pi or another always-on box. That's the recommended setup.

Do I need to root the Fire TV? No. ADB debugging is a standard Developer Option.

Does it work with the official YouTube app? Yes. SmartTube is used only if it's installed. Queue end-detection is tuned for SmartTube; with other apps it relies on the session stopping.

Is it safe? The bot only obeys allow-listed Telegram ids and opens no inbound ports. The HTTP API refuses web pages. See SECURITY.md.

Development

python -m unittest discover -s tests -v   # queue logic, link parsing, media-session parsing (no TV needed)

The project is four Python files with no dependencies:

  • helper/tubequeue.py: HTTP API, ADB, history.
  • helper/playqueue.py: the queue and end-of-video detection.
  • helper/telegram_bot.py: the bot.
  • helper/tvscreen.py: screen mirroring launcher (wraps scrcpy).

The extension is plain Manifest V3 JavaScript.

Credits

  • SmartTube by yuliskov, the ad-free YouTube client this is built around.
  • Not affiliated with or endorsed by Amazon, Google or YouTube. Fire TV is a trademark of Amazon.com, Inc. YouTube is a trademark of Google LLC.

Made by 248Tech · MIT

About

Send YouTube videos to your Fire TV from Chrome or Telegram, with a real play queue. Plays in SmartTube via ADB; tiny Python helper for Raspberry Pi or Windows.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages