Tumgik
#anyways if I find the VOD I'm talking about in my files (and if it isn't too long) maybe I can clip it
Text
Still thinking about the early days of QSMP where Fit would visit Vegetta just to say hi and was completely oblivious to the fact that Vegetta was flirting with him a large majority of the time.
12 notes · View notes
notquiteapex · 3 years
Text
VodBot, and taking off the training wheels.
Part 2 of a series on my own little command line application, VodBot. This one will be much longer than the first! You can read part one here. The images in this part were done in MS Paint because I'm currently stuck in an airport!
Tumblr media
So last we left off, VodBot was in it's shelling out stage. It was able to process data from Twitch's servers and on the local disk and figure out what videos were missing, but it left the biggest function of actually obtaining that footage to the more mature programs. In addition, VodBot didn't help all that much with actually slicing up videos in prep for archival on YouTube, and lastly actually uploading to the archive channel on YouTube. These two things needed to change, for the sake of maintaining the project into the future, and also for me to keep my sanity.
Tumblr media
Fun fact, Twitch uses the same API that's exposed to developers to build the entire website, and it's pretty well documented what OAuth Secret and ID they use, since you can easily find it in the HTML of any Twitch page. In case you don't know, an OAuth Secret and ID is essentially a password and username of a "user". No this does not mean you can easily access anyone's info, channel, etc. because this ID and Secret have limited functions, used only for making the site function on a web browser. In fact, VodBot has its own ID and Secret which are not available, because they're meant to be a secret unless you properly manage its permissions, which I have not (yet). Anyways, the way this little faux-login is used is to access Twitch's database of video data and metadata. It uses a special system called GraphQL, you don't need the details on it for this though. Whenever you pull up a video on your browser on Twitch's site, the ID and Secret are used to log in to this GraphQL database, and pull the relevant data to have it display video on your screen.
Tumblr media
Streams on Twitch, when being watched after the stream is over, are sent in 15 second chunks. This is how many video platforms send video dynamically to your browser, allowing video to load while you watch! It's not always 15 seconds, it varies between platforms like Netflix, YouTube, Twitch, Amazon, etc. The database returns two important bits, first up is all the info on the video segments that Twitch has for a specific video. The other bit, is just all the 15 second video files that Twitch sends to your browser. VodBot is now able to save all these by itself without an extra program, but still requires ffmpeg to stitch it all together as these 15 second video clips use a special protocol and its not as easy as simply opening a file and writing the contents of each 15 seconds one after another.
Once ffmpeg does it's job, VodBot moves the video out to a proper archival location and removes the old metadata and all the 15 second video clips it pulled from Twitch's database. A major issue with this whole implementation is that Twitch, at any moment, can easily change out the ID and Secret, meaning all the apps that rely on it can break. Although it's not currently implemented, it wouldn't be difficult to have VodBot's main configuration file contain the current values and allow them to be changed in case Twitch breaks something.
Next, since we already require VodBot to have ffmpeg, we can use the method I talked about last time to slice videos and prep them for upload. Problem is, we have a lot of functions we need to make accessible from a simple command line interface, so I had to begin thinking about how to organize VodBot's functions.
Tumblr media
I kept it simple enough. Want to download videos? Run `vodbot pull` and VodBot will do all the hard work and download any videos you don't have. You can give it the keywords `vods` or `clips` and it'll pull what you need, and soon giving it a specific video ID will download it too. Want to prepare videos to be sliced or uploaded? Run `vodbot stage add` with the appropriate identifier and VodBot will ask a series of questions about what the video title, description, and relevant timestamps of the VOD or clip to prepare it for upload to YouTube. Running `vodbot stage list` will also list the current videos in queue to upload, along with `vodbot stage rm` to remove them from the stage. Vodbot can output these videos with the appropriate information with `vodbot slice` and the appropriate stage ID, or just `all` with a specific file or folder location respectively. Lastly, `vodbot upload all` uploads all of the stage queue to YouTube, provided you are logged in. You can also just give a specific ID in place of `all` to upload a specific video.
All of these commands have a purpose, or have sub-commands that do something related to each other. Pull and upload also have aliases named download and push respectively, in case you like having either style. Personally I like the git style, but download and upload are a bit more descriptive.
Tumblr media
That's all for now, next time we'll actually get to how Google handles it's exposed API and how it's pretty messy.
For now though, if you'd like to support me, you can follow me on Twitter, Twitch, or buy me a ko-fi!
4 notes · View notes