Giter Club home page Giter Club logo

gotubecast's Introduction

gotubecast

gotubecast is a small Go program which you can use to make your own YouTube TV player.

It connects to the YouTube Leanback API and generates a text stream providing pairing codes, video IDs, play/pause/seek/volume change commands etc. It doesn't have any dependencies and runs on any of the platforms supported by golang. For example, use it on a Raspberry Pi in combination with youtube-dl and omxplayer for a DIY Chromecast clone or make a YouTube TV extension for your favorite media center software.

Build + Install

Provided you have golang correctly set up:

go get github.com/CBiX/gotubecast

Run

With default options:

gotubecast

Minimal dumb YouTube TV example (opens every video in a new browser window, no control possible):

gotubecast -n "Dumb TV" -i dumb-v1 | while read line
do
    cmd="`cut -d ' ' -f1 <<< "$line"`"
    arg="`cut -d ' ' -f2 <<< "$line"`"
    case "$cmd" in
        pairing_code)
            echo "Your pairing code: $arg"
            ;;
        remote_join)
            cut -d ' ' -f3- <<< "$line connected"
            ;;
        video_id)
            xdg-open "https://www.youtube.com/watch?v=$arg" &
            ;;
    esac
done

Usage help:

$ gotubecast -h
Usage of ./gotubecast:
  -d int
		Debug information level. 0 = off; 1 = full cmd info; 2 = timestamp prefix, this changes the output format!
  -i string
		Display App (default "golang-test-838")
  -n string
		Display Name (default "Golang Test TV")
  -s string
		Screen ID (will be generated if empty)

More in the examples folder.

Text stream

The following keys are being written to stdout:

Essential methods

  • pairing_code <aaa-bbb-ccc-ddd>: the device pairing code formatted with separating dashes
  • video_id <id>
  • play
  • pause
  • seek_to <seconds>
  • set_volume <percent>

Other

  • generic_cmd <cmd> <params>: all non-implemented commands
  • remote_join <id> <name>: client connects
  • remote_leave <id>: client disconnects
  • next
  • previous
  • screen_id: The screen ID will be generated if not passed by -s flag. If you want to keep connected devices over restarts, generate it first and pass it from then on.
  • lounge_token, option_sid, option_gsessionid: API internals

Roadmap / TODO

  • dbus interface (for YouTube specific commands as well as connecting to MPRIS supported players)
  • testing
  • video duration
  • autoplay
  • subtitles

gotubecast's People

Contributors

cbix avatar bogoevskig avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.