Show HN: ytcast – cast YouTube videos to your smart TV from command-line (github.com)
hi, this is a project I've been working on and off for the last three months,
it's my first non-trivial, non-hello-world, actually useful (at least to me) go
project. it would be very nice if you could just try the program and see if it
works on your setup!
the readme[0] explains how it works, why I wrote it and how it fits in my "command-line centric" computing environment (there is also a video demo[1] :)).
if you know go, feel free to take a look at the code and review it! I'm still pretty much new to go and I'd love to hear opinions, feedback and tips from more seasoned go developers :)
56 comments
[ 3.0 ms ] story [ 127 ms ] threadas already said, ytcast won't work "directly" with chromecast since they use a different protocol, but there are other projects linked in this thread which work very nice with chromecast!
https://github.com/skorokithakis/catt/
> I loathe "magic" - and love seeing the mechanics of how stuff like this works.
yeah me too :)
[1] https://github.com/skorokithakis/catt
- they use a different protocol for device discovery, catt uses mDNS, ytcast uses DIAL.
- catt requires a chromecast to work, ytcast should work with any DIAL enabled device that supports the YouTube on TV app.
- catt can cast from many sources including local files, ytcast merely "tells" the YouTube on TV app to play videos, so it's limited to YouTube.
and for our needs works perfect.
Castnow, mentioned elsewhere in the thread, seems to be able to cast videos saved on the laptop directly. Our usual routine is to copy to pendrive, move to TV and then switch the TV source to usb. This would be a welcome addition.
> cast videos saved on the laptop directly.... This would be a welcome addition.
yeah i know this would be great, but unfortunately it's unfeasible with the current implementation. what ytcast does is merely "telling" the YouTube on TV app to play videos.
[0]: https://github.com/MarcoLucidi01/bin/blob/master/ytsearch
Continuation searches occur when a user scrolls to the bottom of a search results page.
YouTube (or NewPipe, etc.) sends automated search requests to continue the search, triggered automatically via Javascript when the user scrolls to the bottom of the page.
YouTube continuation searches leak a large amount of unnecessary user data to Google.
1.sh[1] sends continuation searches manually and sends only the minimum ($MIN) data needed to fulfill the request.
It can be used to continue a search indefinitely over an extended period of time. Using an app like NewPipe, often recommended on HN, one could try to do continuation searches by repeatedly scrolling to the bottom of the search results page. However if one goes forward to view a result and then presses a back button, she will be returned to the first page the results, losing all the continuation search results. And if the browser tab or app is closed or crashes, the continuation search results are lost. It is easy to lose one's place when doing continuation searches using a Javascript-enabled browser or app. Using this script, this will never happen.
1.sh only uses TLS1.3 so no server certificate is sent in plaintext over the wire. Nor does it send SNI, i.e., plaintext hostnames on the wire.
ytsearch requires sed, column, awk, jq, fzf, and curl.
1.sh requires sed, netcat, stunnel and flex.
1.sh could be adapted to use curl but how does one disable SNI with curl.
Not to mention curl has a TLS fingerprint that sites may use to try to block requests or treat them with prejudice.
Usage for 1.sh is
To convert our line-oriented JSON to TSV, we can use line-oriented UNIX utilities. In general, this will be faster than jq and more robust for large files.1. 1.sh is a 25 line, 1000 character shell script. https://news.ycombinator.com/item?id=30408770
> ytsearch does not support continuation searches.... Continuation searches occur when a user scrolls to the bottom of a search results page.
true, I never bothered adding "continuation searches" feature to ytsearch because I very rarely scroll down to the second page of results. usually if what I'm looking for is not in the first 4-5 results, I just "refine" the search query.
ytsearch is a quick-and-dirty script that avoids me to open the browser for simple YouTube searches (I stole the idea from the initial version of ytfzf).
> It only retrieves the first 15 results.
that's not true, I always get more than 20-25 results on average and it's usually enough for my use:
> 1.sh only uses TLS1.3 so no server certificate is sent in plaintext over the wire. Nor does it send SNI, i.e., plaintext hostnames on the wire.> 1.sh could be adapted to use curl but how does one disable SNI with curl.
that's pretty cool if you care about this kind of stuff!
> Not to mention curl has a TLS fingerprint that sites may use to try to block requests or treat them with prejudice.
yes I see how this could become a problem.
> ytsearch requires sed, column, awk, jq, fzf, and curl.
> 1.sh requires sed, netcat, stunnel and flex.
what are you implying here? do you think those 6 dependencies are "too much" for ytsearch compared to those of 1.sh?
anyway, it seems that the 2 tools offer a slightly different user experience out-of-the-box:
- 1.sh dumps json and can be used to continue searches without leaking too much data.
- ytsearch allows to quickly select a few urls and it's meant to be used interactively.
> To convert our line-oriented JSON to TSV, we can use line-oriented UNIX utilities. In general, this will be faster than jq and more robust for large files.
faster yes, but how it will be "more robust for large files" than jq? I always thought jq is the right tool for the job when dealing with json.
Providing a list of requirements is a courtesy for the reader.
https://github.com/Reggino/chromecaster
What I mean: I have a Linux box connected to my TV - I want to know if there is a way to cast from a phone to the Linux box, by installing some software on the linux box that makes it appear as a Chromecast to other devices
Also maybe look into OpenMax + Raspicast
Nymphcast [1] is an alternative, but wouldn't be compatible with existing clients, since the protocol is different.
Miraclecast [2] is an implementation of miracast/wi-fi display that runs on Linux. There is also a myriad of alternatives: vnc, raspicast, etc.
Leapcast [3] used to be an implementation of what you want (while using chrome as a black box).
There are some implementations of airplay servers.
And lastly, a lot of media players implement some way of playing on one another (vlc, kodi, jellyfin, plex).
Funnily, you might just be interested in UPNP and DLNA. Support for these is quite robust, but it tends to disappear on newer devices (to the benefit of proprietary solutions like chromecast and airplay).
[1]: http://nyanko.ws/product_nymphcast.php
[2]: https://github.com/albfan/miraclecast
[3]: https://github.com/dz0ny/leapcast
Thanks I'll look into the alternatives you linked
Nymphcast and Kodi work relatively well as a substitute, but aren't integrated in google's products like youtube (you can still use "share to" usually).