项目作者: cbix

项目描述 :
DIY YouTube TV
高级语言: Go
项目地址: git://github.com/cbix/gotubecast.git
创建时间: 2016-08-31T10:39:38Z
项目社区:https://github.com/cbix/gotubecast

开源协议:MIT License

下载


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:

  1. go get cbix.de/gotubecast

Run

With default options:

  1. gotubecast

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

  1. gotubecast -n "Dumb TV" -i dumb-v1 | while read line
  2. do
  3. cmd="`cut -d ' ' -f1 <<< "$line"`"
  4. arg="`cut -d ' ' -f2 <<< "$line"`"
  5. case "$cmd" in
  6. pairing_code)
  7. echo "Your pairing code: $arg"
  8. ;;
  9. remote_join)
  10. cut -d ' ' -f3- <<< "$line connected"
  11. ;;
  12. video_id)
  13. xdg-open "https://www.youtube.com/watch?v=$arg" &
  14. ;;
  15. esac
  16. done

Usage help:

  1. $ gotubecast -h
  2. Usage of ./gotubecast:
  3. -d int
  4. Debug information level. 0 = off; 1 = full cmd info; 2 = timestamp prefix, this changes the output format!
  5. -i string
  6. Display App (default "golang-test-838")
  7. -n string
  8. Display Name (default "Golang Test TV")
  9. -s string
  10. 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 \: the device pairing code formatted with separating dashes
  • video_id \
  • play
  • pause
  • seek_to \
  • set_volume \

Other

  • generic_cmd \ \: all non-implemented commands
  • remote_join \ \: client connects
  • remote_leave \: 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