YouTube - dgl/nextube GitHub Wiki

[Imported by @dgl, thanks to @andypiper for the original content]

One of the included "apps" for the Nextube is a YouTube subscriber counter, which can be configured via the desktop app.

Unfortunately: I couldn't get it to work, out of the box.

I did eventually get it to work by following the steps below:

  • figured out the YouTube API it is using, via digging into the firmware. It is this:

https://www.googleapis.com/youtube/v3/channels?part=statistics&id=CHANNELIDkey=APIKEY>

  • downloaded the config.json file from my Nextube, and found that it contains a youtube_key value. Tested this, and it has exceeded a call quota limit. Basically, out of the box it looks like all of the Nextubes are using the same API key, which runs out of calls for the day fairly quickly.
  • created a new project on Google cloud console and grabbed a key with access to the YouTube API (I set this to be locked down to only having access to the YouTube Data API)
  • the desktop app wants a "Channel ID". This is not the name / URL for the channel, but an internal ID. I got mine from the URL of my logged-in YouTube channel dashboard.
  • replaced the API key in config.json, uploaded, reset, switched over to the YouTube display, waited a few moments, and it now shows subs.

I used curl commands to do the upload and reset:

curl -F [email protected] 'http://[IP-addr]/api/file/upload?path=/config.json' && curl -d '' 'http://[IP-addr]/api/reset'

Implementation details

From tcpdumping the device, it requests this data every 10 minutes (also NTP and weather, although the YouTube requests are offset around 1:30 after those two). So you'll use 6 * 24 = 144 requests/day for a single device. I think we know where their quota went!

It seems the device does not check the certificate at all, I pointed it to a random HTTPS server under my control via forwarding port 443 on my router to it, it made the request fine (i.e. not checking the names on the certificate).

Request was as follows:

GET /youtube/v3/channels?part=statistics&id=<id>&key=<key> HTTP/1.1
host: www.googleapis.com
user-agent: ESP32HTTPClient
accept-encoding: identity;q=1,chunked;q=0.1,*;q=0
⚠️ **GitHub.com Fallback** ⚠️