“By far the biggest time sink that I have is watching YouTube. Since 2008, this website has been my main source of entertainment. I am a huge fan of the platform and many of its content creators. So, I wanted to create something that made it easier to consume my favorite creators newest content. I came up with the idea of making an old-style TV, where the buttons would change to the “Channel” to a different YouTuber and start playing the newest video. Red LED lights on the front would light up when the channel uploads a new video. And when a button is pressed it will open a window playing the newest video.
The most important part of any large project like this is making sure that the code works and that it works well. Before coming up with any design of how it should look. After all what is the point of having a really cool looking unit if it doesn’t function?
This code obviously revolves completely around YouTube. So, we need to extract information about the channels for the website, interpret that data, then create a URL that take use to the newest video uploaded by the selected channel. To do this we are going to be working with googles API. Before we start working with the API were going to need a 2 thing. First, an API key from google. All this takes is going to the google developer console getting a developer’s license and requesting an API key. Second thing that you need to do is download the Google API Client form GitHub. For this project I am working in python so I needed the python client.
The Hart of this project is a Raspberry Pi4. My first attempted at building this I was using a Raspberry Pi2. Which was just too underpowered for video streaming. It would take several minutes to just load the web page. And when the video would play it could only do it for a few seconds before it needed to buffer. So, the switch was made to the newer board. Works great and have no complaints with it. Web pages load fast and video play without buffering.
How the code works is that every 5mins the program will go to each channel’s “all uploads” playlist and get the number of how many videos that are in the playlist. Then it will compare that number to the number of videos that it counted last time it loop or last time the program ran. If the number it just counted is larger than the number it counted last time. Then a new video has been uploaded. Using the IO on the Raspberry Pi, the led will be turned on letting the user know which channel has uploaded and the and the new URL will be ready to go and linked to the button. Once the button is pressed it will open up a web page, go to that URL, turn off the led, and update the saved total uploads value in a TXT file.
Big thing to note, is that this program run off V3 of the YouTube API. At some point the API will be updated and this program will no longer work. But most likely all it would take to fix is changing where the program goes to retrieve information.”