I may be too far down a rabbit hole here but posting in case someone can help…
I have set up automations that allow me to tune to certain channels in YoutubeTV, using ADB commands from a thread that I now cannot find:
- service: androidtv.adb_command
data_template:
entity_id: media_player.tv_adb
command: am start -a android.intent.action.VIEW -d watch/{{ state_attr('sensor.youtubetv_channel_lookup',
'channels')[channel] }} -n com.google.android.youtube.tvunplugged/com.google.android.apps.youtube.tvunplugged.activity.MainActivity
The trick here is having to map the channel (e.g. ESPN) to YoutubeTV’s channel code (ESPN is currently bj3v-DQPnNs). I thought I was smart and I’d set up a sensor with the mappings, but as it turns out apparently they rotate those from time to time, which breaks my automations, and I’m tired of updating them manually.
So…I’ve been trying to come up with a way to scrape these from their site but it’s proven more challenging than I expected.
Stepping back – has anyone come up with a fool proof way to do this? Or maybe have any ideas about scraping?
I’ll be glad to share more details of what I have working if anyone is interested, but as I said it breaks about once a month, give or take…
I went there incognito and I could see the urls.
Then there is a “see all channels” button which leads to here:
If these are the real links then at least you don’t need to auth.
Since I’m typing on my phone I haven’t been able to look at the HTML but whatever it is, it’s possible.
I just took a look… seems like those are the same URL’s except they are prepended with the channel name in that list and not so in the guide.
so in the channel list you linked. you’ll see abc-blahblahlbha but in the real guide once logged in there is not abc- (abc- being the channel name, cbs-, fox-, etc)
so it may be a good starting point to scrape.
Yes… on the page you linked not signed in for channel ABC if I copy the link there and
put that exact link into my signed in page, it removes the abc- part and brings up the ABC channel ‘page’
I’m also manually updating by grabbing the URL from LiveTV in a web browser, and luckily it doesn’t change that often. CNN is currently https://tv.youtube.com/watch/4Ogm6iKafo4, for instance. ESPN is https://tv.youtube.com/watch/bj3v-DQPnNs. If there’s a way to scrape those URLs and update them automatically, I’m all in.
Lol, either we watch too much TV (quite possible) or have bad timing, but it seems like we hit it regularly enough to be annoying. Then we got super lazy and just used the ones that worked, and now they’re all broken. Worse, I don’t think they change them all together, and some seem to change less frequently than others.
Probably, they’re just tracking the channels I watch, lol.
I only use it to emulate a “regular” TV so that I get live TV when I turn the TV on, and it just goes straight to CNN. It used to change more frequently, but it’s every few months now that I’ll notice that my automation no longer works.
Ah, that explains it. Things I had working at one point in time:
Custom Alexa Skill, allowing “Ask Television to Tune to [Channel]”
Remembering Previous Channel, allowing Alexa “Ask Television to go to previous channel”
Dedicated Google Calendar allowing scheduled tuning. E.g. add a calendar entry for “ESPN” at 5 p.m. and whatever TV is on will tune to that.
Transferring channel from Living Room to Bedroom, i.e. turning on Bedroom TV will tune to whatever the Living Room was last tuned to.
I told you, we watch too much TV.
But it all needs this mapping. I.e. if you were last on channel X it needs to be able to look up that X = blahblahblah to send you back to that channel.
watch wont work because it has to be browse. and you cant use that to go directly to live tv because each show has it’s own ID. so best you can do is browse to the channel.
you have a back slash above. can you try re-sending with a forward slash?
One really frustrating thing about Youtube TV is trying to Google anything about it. 99.9% of the hits you get are just for Youtube, and there just aren’t enough people hacking Youtube TV for this type of thing to foster a community.
This finally got annoying enough for me to get back to. I don’t have a great solution, but I’ve taken another step forward, so posting here in case it helps anyone, or someone can take the next step forwards.
I haven’t been able to call that directly without getting blocked by their automation detection. So what I’m doing now instead is to manually load the website (tv.youtube.com/live) with dev tools loaded, and copy/pasting the results of the above file to my server. So now I can get all the updated channels at once just by pulling/updating this file. Then I’ve written the attached php to parse the codes from their file into JSON that can be consumed in a REST sensor within HA.